Hi!
Kindly ask you to help me with understanding an error that I have with LOOP function. My is LOOP is following: vector str= dCLICK.1.20120315 to email. LOOP #I=1 to 101. if cases=1 and str(#I)="" str(#I)=LAG(str(#I)). END LOOP IF CHAR.INDEX(str(#I),"@")>0. And I have this error: >Error # 4002 >A program error has occurred: An impossible situation has been encountered in >transformations. This includes invalid operation codes, impossible subroutine >arguments, impossible values returned by subroutines, etc. Please note the >circumstances under which this error occurred, attempting to replicate it if >possible, and then notify Technical Support. >This is an error from which the application cannot recover. >The SPSS Statistics run will terminate now. P.S. vector str defines set of string variables. Many thanx in advance! -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Error-in-LOOP-tp5683615.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
|
Possibilities:
From the FM: "A single vector must comprise all numeric variables or all string variables. The string variables must have the same length." I doubt that the second condition is satisfied! The first might not apply either? *LAG cannot be applied to VECTORS!!! DO REPEAT might be a better solution as none of the above limitations apply? -- It might be useful to describe *WHAT* you are attempting to do. not sure what the variable "cases" is or its significance. Looks like you are attempting to fill variables consisting of " " with the value from the preceding row and terminate search upon encountering any field containing a @ in a given row of data? COMPUTE #found=0. DO REPEAT str=dCLICK.1.20120315 to email. + IF $CASENUM > 1 AND NOT (#found) AND str=" " str=LAG(str). + IF CHAR.INDEX(str(#I),"@")>0 #found=1. END REPEAT. Does the above solve the problem? ---- It seems (to me) that the SPSS Processor could provide a more informative error message ;-)
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?" |
Thank you very-very much, David!
Final syntax looks even simpler: DO REPEAT str=dCLICK.1.20120315 to email. + IF $CASENUM > 1 AND str="" AND LAG(cases)=1 str=LAG(str). END REPEAT. EXECUTE. The problem was with LAG + vector. /*IF CHAR.INDEX(str(#I),"@")>0 #found=1.*/ is not necessary now. I need to stop on "email" variable but number of variables in the set is not constant. So, I didn't know how to limit maximum repetition for LOOP. I spent whole day trying to understand how to make this operation:) Also tried DO REPEAT but smth went wrong. I'll be greatfull if you open me a secret what "+" is used for and why do I need to put $CASENUM > 1 condition. Many thanks! |
In reply to this post by kosetsky
"... understanding an error" -
Something happened, which definitely should not have happened, and SPSS found itself in a state which should *never* arise. The message asks that you replicate the error: If it happens every time, then it will not be effect of another program (virus, say) that has interfered with the contents of the SPSS program memory in a unique, one-time manner. So, it is pretty-much impossible to say what happens if you can't run it twice and get the same thing. Ir it replicates, then it might be possible to track it down. I would add -- re-boot, and run again, because re-booting manages to clear up a lot of bad behavior on Windows. Especially, it would be good if you can confirm it on another computer, because that would show the problem is not due to a corruption of the version of SPSS on your own computer. Anyway, if the code always does wrong, then "Notify Technical Support". David suggest that, perhaps, SPSS allocated a vector without making sure that all the variables were string, and of the same length. If that is the problem, then he gives a work-around; but SPSS should be informed so that an appropriate error message would be generated at that earlier mis-step. -- Rich Ulrich > Date: Thu, 3 May 2012 09:04:19 -0700 > From: [hidden email] > Subject: Error in LOOP > To: [hidden email] > > Hi! > Kindly ask you to help me with understanding an error that I have with LOOP > function. > > My is LOOP is following: > > vector str= dCLICK.1.20120315 to email. > LOOP #I=1 to 101. > if cases=1 and str(#I)="" str(#I)=LAG(str(#I)). > END LOOP IF CHAR.INDEX(str(#I),"@")>0. > > > And I have this error: > > >Error # 4002 > >A program error has occurred: An impossible situation has been encountered > in > >transformations. This includes invalid operation codes, impossible > subroutine > >arguments, impossible values returned by subroutines, etc. Please note the > >circumstances under which this error occurred, attempting to replicate it > if > >possible, and then notify Technical Support. > >This is an error from which the application cannot recover. > >The SPSS Statistics run will terminate now. > > P.S. > vector str defines set of string variables. > Many thanx in advance! > > .... |
Administrator
|
In reply to this post by kosetsky
+ unnecessary for Interactive (syntax window submission), files used in INSERT, but required for INCLUDE (obsolete in newer versions) but useful to visually demarcate nesting levels.
$CASENUM to protect code from trying to LAG first case. --- example of nesting: DO REPEAT v=varlist. + DO IF (condition1). + LOOP. + DO IF (condition2). + ..... + END LOOP IF (condition). + END IF. END REPEAT. --- vs: DO REPEAT v=varlist. DO IF (condition1). LOOP. DO IF (condition2). ..... END LOOP IF (condition). END IF. END REPEAT.
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 Rich Ulrich
The application does give an appropriate
error message if you try to mix strings and numerics or string of different
lengths in the same vector:
Error # 4263 in column 18. Text: z The list of existing variables on the VECTOR command includes incompatible variables. A single vector must be composed entirely of numeric variables or entirely of string variables of the same length. So apparently something else is going on. Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] Phone: 312.893.4922 | T/L: 206-4922 From: Rich Ulrich <[hidden email]> To: [hidden email] Date: 05/03/2012 01:29 PM Subject: Re: Error in LOOP Sent by: "SPSSX(r) Discussion" <[hidden email]> "... understanding an error" - Something happened, which definitely should not have happened, and SPSS found itself in a state which should *never* arise. The message asks that you replicate the error: If it happens every time, then it will not be effect of another program (virus, say) that has interfered with the contents of the SPSS program memory in a unique, one-time manner. So, it is pretty-much impossible to say what happens if you can't run it twice and get the same thing. Ir it replicates, then it might be possible to track it down. I would add -- re-boot, and run again, because re-booting manages to clear up a lot of bad behavior on Windows. Especially, it would be good if you can confirm it on another computer, because that would show the problem is not due to a corruption of the version of SPSS on your own computer. Anyway, if the code always does wrong, then "Notify Technical Support". David suggest that, perhaps, SPSS allocated a vector without making sure that all the variables were string, and of the same length. If that is the problem, then he gives a work-around; but SPSS should be informed so that an appropriate error message would be generated at that earlier mis-step. -- Rich Ulrich > Date: Thu, 3 May 2012 09:04:19 -0700 > From: [hidden email] > Subject: Error in LOOP > To: [hidden email] > > Hi! > Kindly ask you to help me with understanding an error that I have with LOOP > function. > > My is LOOP is following: > > vector str= dCLICK.1.20120315 to email. > LOOP #I=1 to 101. > if cases=1 and str(#I)="" str(#I)=LAG(str(#I)). > END LOOP IF CHAR.INDEX(str(#I),"@")>0. > > > And I have this error: > > >Error # 4002 > >A program error has occurred: An impossible situation has been encountered > in > >transformations. This includes invalid operation codes, impossible > subroutine > >arguments, impossible values returned by subroutines, etc. Please note the > >circumstances under which this error occurred, attempting to replicate it > if > >possible, and then notify Technical Support. > >This is an error from which the application cannot recover. > >The SPSS Statistics run will terminate now. > > P.S. > vector str defines set of string variables. > Many thanx in advance! > > .... |
In reply to this post by David Marso
So the original problem was that a loop to 101 tried to read
(and set values for) too many variables in a vector that was shorter than 101. I wonder if SPSS detected this and quit -- in which case, I agree that there should be a better message -- or if it carried out instructions to store values in illegal locations, until it corrupted itself and finally detected another problem. - This reminds me of what I have read about "exploits" of some worms and viruses, which read beyond defined vectors to steal information that should not be accessible. -- Rich Ulrich > Date: Thu, 3 May 2012 11:38:11 -0700 > From: [hidden email] > Subject: Re: Error in LOOP > To: [hidden email] > ... [solution, explained, and comments on solution from the original poster] |
In reply to this post by kosetsky
The plus sign doesn't really do anything...unless
you're running in the old "batch" mode, in which case it's just
a way to allow indenting of commands. In the standard "interactive"
mode, you can indent commands as much as you want without needing to stick
something in the first column.
Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] Phone: 312.893.4922 | T/L: 206-4922 From: kosetsky <[hidden email]> To: [hidden email] Date: 05/03/2012 04:10 PM Subject: Re: Error in LOOP Sent by: "SPSSX(r) Discussion" <[hidden email]> Thank you very-very much, David! Final syntax looks even simpler: DO REPEAT str=dCLICK.1.20120315 to email. + IF $CASENUM > 1 AND str="" AND LAG(cases)=1 str=LAG(str). END REPEAT. EXECUTE. The problem was with LAG + vector. /*IF CHAR.INDEX(str(#I),"@")>0 #found=1.*/ is not necessary now. I need to stop on "email" variable but number of variables in the set is not constant. So, I didn't know how to limit maximum repetition for LOOP. I spent whole day trying to understand how to make this operation:) Also tried DO REPEAT but smth went wrong. I'll be greatfull if you open me a secret what "+" is used for and why do I need to put $CASENUM > 1 condition. Many thanks! -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Error-in-LOOP-tp5683709p5683924.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 Rich Ulrich
My DO REPEAT syntax now works well. But I can't use it if I define a set of both numeric and string variables.
How can I check variable type before using logical expression in transformation to avoid error message? PS. Regarding the previous error I've had exactly 101 string variables in the set and they were unified by ALTER TYPE function. So, doubt that this could be a reason of error. |
One way to do this would be to define macros
for the string and numeric variables and use separate DO REPEAT loops for
each.
Statistics has no built-in way to check for variable type, but there is an extension command SPSSINC SELECT VARIABLES that can build macros based on variable metadata. Here is an example. SPSSINC SELECT VARIABLES MACRONAME="!numeric" /PROPERTIES TYPE=NUMERIC. desc !numeric. SPSSINC SELECT VARIABLES MACRONAME="!string" /PROPERTIES TYPE=STRING. DO REPEAT z = !numeric. compute z = z*z. end repeat. Other selection criteria can also be used in the extension command such as specific names or patterns in the names. See the dialog that appears after installation as Utilities>Define Variable Macro or run SPSSINC SELECT VARIABLES /HELP for details. To use this extension command, you need to install the Python Essentials for your version of Statistics and the SPSSINC SELECT VARIABLES command. These are available from the SPSS Community website (www.ibm.com/developerworks/spssdevcentral). Click on Downloads for SPSS Statistics. On that page, you will see a link to the Python Essentials for various versions of Statistics. There is also a link to the Extension Commands collection. If you are on Win7, be sure to do the installs using Run As Administrator or see the FAQ on the site for solving permissions problems. HTH, Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: kosetsky <[hidden email]> To: [hidden email] Date: 05/04/2012 07:52 AM Subject: Re: [SPSSX-L] Error in LOOP Sent by: "SPSSX(r) Discussion" <[hidden email]> My DO REPEAT syntax now works well. But I can't use it if I define a set of both numeric and string variables. How can I check variable type before using logical expression in transformation to avoid error message? PS. Regarding the previous error I've had exactly 101 string variables in the set and they were unified by ALTER TYPE function. So, doubt that this could be a reason of error. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Error-in-LOOP-tp5683709p5685426.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 kosetsky
DO REPEAT supports multiple definitions: DO REPEAT x = stringvar1 stringvar99 stringvar23 /y = numvar1 to numvar15 . You can then process each list of variables with different commands. Jim Marks Sr Market Research Manager National Market Research Kaiser Foundation Health Plan of the Mid-Atlantic States, Inc. 2101 E. Jefferson St. Rockville, MD 20852 Phone: (301) 816-6822 Cell Phone: (301) 456-6164 NOTICE TO RECIPIENT: If you are not the intended recipient of this e-mail, you are prohibited from sharing, copying, or otherwise using or disclosing its contents. If you have received this e-mail in error, please notify the sender immediately by reply e-mail and permanently delete this e-mail and any attachments without reading, forwarding or saving them. Thank you. From: kosetsky <[hidden email]> To: [hidden email] Date: 05/04/2012 09:49 AM Subject: Re: Error in LOOP Sent by: "SPSSX(r) Discussion" <[hidden email]> My DO REPEAT syntax now works well. But I can't use it if I define a set of both numeric and string variables. How can I check variable type before using logical expression in transformation to avoid error message? PS. Regarding the previous error I've had exactly 101 string variables in the set and they were unified by ALTER TYPE function. So, doubt that this could be a reason of error. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Error-in-LOOP-tp5683709p5685426.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 |
DO REPEAT requires that each stand-in variables
have the same number of implied or explicit values. So your example probably
won't work.
Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] Phone: 312.893.4922 | T/L: 206-4922 From: Jim Marks <[hidden email]> To: [hidden email] Date: 05/04/2012 10:06 AM Subject: Re: Error in LOOP Sent by: "SPSSX(r) Discussion" <[hidden email]> DO REPEAT supports multiple definitions: DO REPEAT x = stringvar1 stringvar99 stringvar23 /y = numvar1 to numvar15 . You can then process each list of variables with different commands. Jim Marks Sr Market Research Manager National Market Research Kaiser Foundation Health Plan of the Mid-Atlantic States, Inc. 2101 E. Jefferson St. Rockville, MD 20852 Phone: (301) 816-6822 Cell Phone: (301) 456-6164 NOTICE TO RECIPIENT: If you are not the intended recipient of this e-mail, you are prohibited from sharing, copying, or otherwise using or disclosing its contents. If you have received this e-mail in error, please notify the sender immediately by reply e-mail and permanently delete this e-mail and any attachments without reading, forwarding or saving them. Thank you. From: kosetsky <[hidden email]> To: [hidden email] Date: 05/04/2012 09:49 AM Subject: Re: Error in LOOP Sent by: "SPSSX(r) Discussion" <[hidden email]> My DO REPEAT syntax now works well. But I can't use it if I define a set of both numeric and string variables. How can I check variable type before using logical expression in transformation to avoid error message? PS. Regarding the previous error I've had exactly 101 string variables in the set and they were unified by ALTER TYPE function. So, doubt that this could be a reason of error. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Error-in-LOOP-tp5683709p5685426.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 Jim Marks
Not so fast!
The lists have to be the same length and they are processed in parallel. That drastically limits such an approach. The core issue is being able to *NOT* have to manually type in all the variable names after having to sift through and pull strings from numbers. JoNoH's EXTENSION doohicky is probably the best way. ---
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 Rick Oliver-3
*oops* I thought the limitation only applied if I wanted to use both lists in the same expression. DO REPEAT x = stringvar1 stringvar99 stringvar23 . <commands.> END REPEAT DOREPEAT /y = numvar1 to numvar15 . <commands>. END REPEAT. Jim Marks Sr Market Research Manager National Market Research Kaiser Foundation Health Plan of the Mid-Atlantic States, Inc. 2101 E. Jefferson St. Rockville, MD 20852 Phone: (301) 816-6822 Cell Phone: (301) 456-6164 NOTICE TO RECIPIENT: If you are not the intended recipient of this e-mail, you are prohibited from sharing, copying, or otherwise using or disclosing its contents. If you have received this e-mail in error, please notify the sender immediately by reply e-mail and permanently delete this e-mail and any attachments without reading, forwarding or saving them. Thank you. From: Rick Oliver <[hidden email]> To: Jim T Marks/MD/KAIPERM@KAIPERM Cc: [hidden email] Date: 05/04/2012 11:12 AM Subject: Re: Error in LOOP DO REPEAT requires that each stand-in variables have the same number of implied or explicit values. So your example probably won't work. Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] Phone: 312.893.4922 | T/L: 206-4922 From: Jim Marks <[hidden email]> To: [hidden email] Date: 05/04/2012 10:06 AM Subject: Re: Error in LOOP Sent by: "SPSSX(r) Discussion" <[hidden email]> DO REPEAT supports multiple definitions: DO REPEAT x = stringvar1 stringvar99 stringvar23 /y = numvar1 to numvar15 . You can then process each list of variables with different commands. Jim Marks Sr Market Research Manager National Market Research Kaiser Foundation Health Plan of the Mid-Atlantic States, Inc. 2101 E. Jefferson St. Rockville, MD 20852 Phone: (301) 816-6822 Cell Phone: (301) 456-6164 NOTICE TO RECIPIENT: If you are not the intended recipient of this e-mail, you are prohibited from sharing, copying, or otherwise using or disclosing its contents. If you have received this e-mail in error, please notify the sender immediately by reply e-mail and permanently delete this e-mail and any attachments without reading, forwarding or saving them. Thank you. From: kosetsky <[hidden email]> To: [hidden email] Date: 05/04/2012 09:49 AM Subject: Re: Error in LOOP Sent by: "SPSSX(r) Discussion" <[hidden email]> My DO REPEAT syntax now works well. But I can't use it if I define a set of both numeric and string variables. How can I check variable type before using logical expression in transformation to avoid error message? PS. Regarding the previous error I've had exactly 101 string variables in the set and they were unified by ALTER TYPE function. So, doubt that this could be a reason of error. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Error-in-LOOP-tp5683709p5685426.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 |
Free forum by Nabble | Edit this page |