Happy New Year Everyone.
I was wondering if it was possible to make comments within code? I have a large set of recodes that I would like to complete; however, I would like to identify what is being changed by the code and why. For example, I have included a snippet of the code with my attempted comment code which does not work. NUMERIC E_CODE_R (F5.4). RECODE E_CODE (516.1993=601.1993) */ recode historical expenditures for computer infrastructure to general operations. (516.1994=601.1994) (516.1995=601.1995) (516.1996=601.1996) (516.1997=601.1997) (612.1993=602.1993) */ recode historical expenditures for programs to network operations . (ELSE=COPY) INTO E_CODE_R. EXECUTE. Any suggestions on how to comment on the code at this level would be greatly appreciated. Thank you, Damir |
Administrator
|
Try this:
NUMERIC E_CODE_R (F5.4). RECODE E_CODE (516.1993=601.1993) /* recode historical expenditures for computer infrastructure to general operations */ (516.1994=601.1994) (516.1995=601.1995) (516.1996=601.1996) (516.1997=601.1997) (612.1993=602.1993) /* recode historical expenditures for programs to network operations */ (ELSE=COPY) INTO E_CODE_R. EXECUTE.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
In reply to this post by DKUKEC
Thank you Bruce,
Your solution worked with the RECODE; now I am wondering about the IF command and commenting... IF E_CODE = 516.1993 V4_R = 601 . IF E_CODE = 516.1994 V4_R = 601 . IF E_CODE = 516.1995 V4_R = 601 . / * TEST * / IF E_CODE = 516.1996 V4_R = 601 . IF E_CODE = 516.1997 V4_R = 601 . EXECUTE. Is there a way to comment within this syntax as well. I did try the above and it did not work. Thank you Damir |
In reply to this post by Bruce Weaver
Maybe Bruce's post was mangled in the mail.
Comments cannot be continued across lines within commands, and I
don't get the */* lines.
This would work. RECODE jobcat (1=10) /* the ones (2=20) /* the twos (3=30) /* the threes (ELSE=99) INTO rc. Or even this. RECODE jobcat (1 /* the ones */ =10) (2 /* the twos */=20) (3 /* the threes */ =30) (ELSE=99) INTO rc. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Bruce Weaver <[hidden email]> To: [hidden email], Date: 01/06/2014 01:49 PM Subject: Re: [SPSSX-L] Commenting within syntax? Sent by: "SPSSX(r) Discussion" <[hidden email]> Try this: NUMERIC E_CODE_R (F5.4). RECODE E_CODE (516.1993=601.1993) */* recode historical expenditures for computer infrastructure to general operations */* (516.1994=601.1994) (516.1995=601.1995) (516.1996=601.1996) (516.1997=601.1997) (612.1993=602.1993) */* recode historical expenditures for programs to network operations */* (ELSE=COPY) INTO E_CODE_R. EXECUTE. DKUKEC wrote > Happy New Year Everyone. > > I was wondering if it was possible to make comments within code? I have a > large set of recodes that I would like to complete; however, I would like > to identify what is being changed by the code and why. For example, I > have included a snippet of the code with my attempted comment code which > does not work. > > NUMERIC E_CODE_R (F5.4). > RECODE E_CODE > (516.1993=601.1993) */ recode historical expenditures for computer > infrastructure to general operations. > (516.1994=601.1994) > (516.1995=601.1995) > (516.1996=601.1996) > (516.1997=601.1997) > (612.1993=602.1993) */ recode historical expenditures for programs to > network operations . > (ELSE=COPY) INTO E_CODE_R. > EXECUTE. > > Any suggestions on how to comment on the code at this level would be > greatly appreciated. > > Thank you, > Damir ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Commenting-within-syntax-tp5723799p5723800.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by DKUKEC
From
http://www.dummies.com/how-to/content/spss-syntax-language-comments.html Three types of comments: (The first takes me back to Fortran days ...) COMMENT This is a comment and will not be executed. * This is a comment and will continue to be a comment until the terminating period. /* This is a comment and will continue to be a comment until the terminating asterisk-slash */ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by DKUKEC
Put a period after the */
IF E_CODE = 516.1995 V4_R = 601. / * TEST * /. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of DKUKEC Sent: Monday, January 06, 2014 4:02 PM To: [hidden email] Subject: Re: [SPSSX-L] Commenting within syntax? Thank you Bruce, Your solution worked with the RECODE; now I am wondering about the IF command and commenting... IF E_CODE = 516.1993 V4_R = 601 . IF E_CODE = 516.1994 V4_R = 601 . IF E_CODE = 516.1995 V4_R = 601 . / * TEST * / IF E_CODE = 516.1996 V4_R = 601 . IF E_CODE = 516.1997 V4_R = 601 . EXECUTE. Is there a way to comment within this syntax as well. I did try the above and it did not work. Thank you Damir -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Commenting-within-syntax-tp5723799p5723801.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by DKUKEC
Don't put a blank between the / and the
*.
if jobcat eq 3 /* a manager */ manager=1. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: DKUKEC <[hidden email]> To: [hidden email], Date: 01/06/2014 02:21 PM Subject: Re: [SPSSX-L] Commenting within syntax? Sent by: "SPSSX(r) Discussion" <[hidden email]> Thank you Bruce, Your solution worked with the RECODE; now I am wondering about the IF command and commenting... IF E_CODE = 516.1993 V4_R = 601 . IF E_CODE = 516.1994 V4_R = 601 . IF E_CODE = 516.1995 V4_R = 601 . / * TEST * / IF E_CODE = 516.1996 V4_R = 601 . IF E_CODE = 516.1997 V4_R = 601 . EXECUTE. Is there a way to comment within this syntax as well. I did try the above and it did not work. Thank you Damir -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Commenting-within-syntax-tp5723799p5723801.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
In reply to this post by Jon K Peck
Jon, I bolded the embedded comments in Nabble, but it came across differently in your e-mail. To see it the way I intended it, view it here:
http://spssx-discussion.1045642.n5.nabble.com/Commenting-within-syntax-tp5723799p5723800.html Cheers, Bruce
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Administrator
|
In reply to this post by MLIves
Furthermore, because this is a comment following a command (rather than a comment embedded within a command), you don't really need the final */. I.e., you could do this:
IF E_CODE = 516.1995 V4_R = 601 . / * Comment here .
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Administrator
|
In reply to this post by DKUKEC
Other have addressed the issue at hand /* rather than / *.
I will add only the following for those inclined to use MACROS . SPSS permits the following sort of comments COMMENT * /* Please note the side effects when a macro name is embedded in the first 2 types of comment string! DEFINE MyDogAteMyComment () . ECHO 'bad dog' . !ENDDEFINE . COMMENT this is a comment MyDogAteMyComment. ECHO "COMMENT". * This is a comment MyDogAteMyComment. ECHO "*". /* This is also a comment MyDogAteMyComment */. ECHO "/*". ECHO "Demo Over". ------------------- OUTPUT -------------- COMMENT this is a comment MyDogAteMyComment. bad dog ECHO "COMMENT". COMMENT * This is a comment MyDogAteMyComment. bad dog ECHO "*". * /* This is also a comment MyDogAteMyComment */. ECHO "/*". /* ECHO "Demo Over". Demo Over
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
I recommend in macros to use /* even at the beginning of the
line (instead of *). It escapes some problems which can
occure if you do not use periods in the end of macro statements and
do use pseudoindentation in front of regular syntax statements.
07.01.2014 2:02, David Marso пишет:
Other have addressed the issue at hand /* rather than / *. I will add only the following for those inclined to use MACROS . SPSS permits the following sort of comments COMMENT * /* Please note the side effects when a macro name is embedded in the first 2 types of comment string! DEFINE MyDogAteMyComment () . ECHO 'bad dog' . !ENDDEFINE . COMMENT this is a comment MyDogAteMyComment. ECHO "COMMENT". * This is a comment MyDogAteMyComment. ECHO "*". /* This is also a comment MyDogAteMyComment */. ECHO "/*". ECHO "Demo Over". ------------------- OUTPUT -------------- COMMENT this is a comment MyDogAteMyComment. bad dog ECHO "COMMENT". COMMENT * This is a comment MyDogAteMyComment. bad dog ECHO "*". * /* This is also a comment MyDogAteMyComment */. ECHO "/*". /* ECHO "Demo Over". Demo Over |
Thank you all for your assistance and information.
Much appreciated. Sincerely, Damir |
In reply to this post by DKUKEC
At 03:30 PM 1/6/2014, DKUKEC wrote:
>I have a large set of recodes that I would like to complete; >however, I would like to identify what is being changed by the code and why. > >NUMERIC E_CODE_R (F5.4). >RECODE E_CODE > (516.1993=601.1993) */ recode historical expenditures for computer >infrastructure to general operations. > (516.1994=601.1994) > (516.1995=601.1995) > (516.1996=601.1996) > (516.1997=601.1997) > (612.1993=602.1993) */ recode historical expenditures for programs to >network operations . >(ELSE=COPY) INTO E_CODE_R. A point about coding: It looks like you have expenditure category (like 516="computer operations") and year (like 1993, 1994, etc.) combined in a single numeric variable, with the year being the fractional part. That's risky, because most decimal fractions are not stored exactly in SPSS -- SPSS uses binary. That means that occasionally a mathematically correct comparison will fail in SPSS, if it relies on two fractions being exactly equal. I don't know whether there's any risk your RECODE clauses will fail, but they do assume exact values of the variable. I'd recommend separate variables for category and year; or, if you want to combine them, make them eight-character strings instead of numbers. (Or combine them, but as *integer* numbers, like 5161993 -- and I know that's less readable.) ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Free forum by Nabble | Edit this page |