hi all,
I have a file with e.g. 5 rows. Amongst other output I want to display the words "2nd part" at a specific point in the output, once. I tried PRINT but it prints "2nd part" 5 times ie. as many rows as there are in the file. I tried LOOP #I=1 TO 1. PRINT / '2nd part'. END LOOP. but it still prints 5 times, along with the fact that it does not immediately execute the command but does so after the next one has been executed. I also tried DISPLAY but I can't do it. Any ideas? |
Administrator
|
The LOOP ... END LOOP is performed for EACH case in the file!
Do what I suggested yesterday!!! I am not going to repeat myself here. --
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?" |
In reply to this post by xenia
PRINT is not executed until some command
that requires a data pass is encountered, and a loop cannot contain a command
that requires a data pass, since it's part of the transformation language,
but...
loop #i=1 to 5. do if #i=2. print / '2nd part' end if. end loop. Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: xenia <[hidden email]> To: [hidden email], Date: 11/20/2012 11:42 AM Subject: print string once Sent by: "SPSSX(r) Discussion" <[hidden email]> hi all, I have a file with e.g. 5 rows. Amongst other output I want to display the words "2nd part" at a specific point in the output, once. I tried PRINT but it prints "2nd part" 5 times ie. as many rows as there are in the file. I tried LOOP #I=1 TO 1. PRINT / '2nd part'. END LOOP. but it still prints 5 times, along with the fact that it does not immediately execute the command but does so after the next one has been executed. I also tried DISPLAY but I can't do it. Any ideas? -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/print-string-once-tp5716352.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 David Marso
You suggested FIRST in MATCH FILE if my variable starts from 2, but I can easily make it start from 1, so didn't do that. For the PRINT problem you suggested enclosing in DO IF, END IF, which is what I isolated and described here, but it still does not do what I want.
|
In reply to this post by Rick Oliver-3
I do that but it says "transformations pending" and won't print "2nd part".
I try : loop #i=1 to 5. do if #i=2. print / '2nd part'. end if. end loop. SAVE OUTFILE='H:\projects\a.sav' /COMPRESSED. and again it prints 5 times, not once. On 20 November 2012 17:59, Rick Oliver <[hidden email]> wrote: PRINT is not executed until some command that requires a data pass is encountered, and a loop cannot contain a command that requires a data pass, since it's part of the transformation language, but... |
Administrator
|
In reply to this post by xenia
By opening a new thread you have destroyed the context of your inquiry.
<recap> You have repeated values of an id and you wish to analyze each id separately and have labeling along the way. </recap> Where your variable starts is unimportant!!! SORT CASES BY ID. MATCH FILES / FILE * / FIRST=@TOP@ / BY ID. DO IF @TOP@. PRINT ID. END IF. ---
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?" |
Administrator
|
In reply to this post by xenia
You are not paying attention!!!
The transformations are performed for EVERY CASE unless otherwise specified (ie DO IF...) OTOH!!!! Rick's LOOP biz is generated for each case!!! Comprendes? ---
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?" |
yes, I understand, however that was my reply to R.Oliver which I tried out and replied to before I read your second reply. The loop is for every case from 1 to 5, but there is a do if #i=2 in there, so it "says" print only for #i=2, so shouldn't the print be executed only once, even if it is within the loop? i takes the value 2 once. Except if I'm interpreting the meaning of the do if #i=2 wrong.
|
Administrator
|
Part of the problem here is that you opened a new thread with a partial question from a previous thread.
Hence, Rick perhaps did not have the necessary context to understand your conundrum. ---- "yes, I understand"... Are you positive about that? -- #i in your data with 5 ROWS takes the value of 2 precisely 5 times. Hence printed 5 times. "Except if I'm interpreting the meaning of the do if #i=2 wrong." That would seem to be the case!.
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?" |
In reply to this post by xenia
Does using a comment (and having 'Display syntax in log' option checked) not work?
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of xenia Sent: Tuesday, November 20, 2012 11:29 AM To: [hidden email] Subject: [SPSSX-L] print string once hi all, I have a file with e.g. 5 rows. Amongst other output I want to display the words "2nd part" at a specific point in the output, once. I tried PRINT but it prints "2nd part" 5 times ie. as many rows as there are in the file. I tried LOOP #I=1 TO 1. PRINT / '2nd part'. END LOOP. but it still prints 5 times, along with the fact that it does not immediately execute the command but does so after the next one has been executed. I also tried DISPLAY but I can't do it. Any ideas? -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/print-string-once-tp5716352.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 PRIVILEGED AND CONFIDENTIAL INFORMATION This transmittal and any attachments may contain PRIVILEGED AND CONFIDENTIAL information and is intended only for the use of the addressee. If you are not the designated recipient, or an employee or agent authorized to deliver such transmittals to the designated recipient, you are hereby notified that any dissemination, copying or publication of this transmittal is strictly prohibited. If you have received this transmittal in error, please notify us immediately by replying to the sender and delete this copy from your system. You may also call us at (309) 827-6026 for assistance. ===================== 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 |