RECODE LOOP

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

RECODE LOOP

jjek
Dear all,

Executing the following syntax:

DATASET ACTIVATE DataSet1.
VECTOR UNIQUE_ID = UNIQUE_ID.1 TO UNIQUE_ID.223.
LOOP #X = 1 TO 223.
DO IF (ANY(UNIQUE_ID(#X),IDFA2010.1 TO IDFA2010.223,IDMO2010.1 TO IDMO2010.223) = 0).
RECODE UNIQUE_ID(#X) (ELSE=SYSMIS).
END IF.
EXECUTE.
END LOOP.

I receive the error:

>Error # 4631 in column 8.  Text: UNIQUE_ID
>On the RECODE command, the list of variables to be recoded includes the name
>of a nonexistent variable.
>This command not executed.
END IF.
EXECUTE.

>Warning # 142.  Command name: EXECUTE
>LOOP has no effect on this command.

>Error # 4095.  Command name: EXECUTE
>The transformations program contains an unclosed LOOP, DO IF, or complex file
>structure.  Use the level-of-control shown to the left of the PASW Statistics
>commands to determine the range of LOOPs and DO IFs.
>This command not executed.

I cannot figure out why this syntax doesn't work. Can anybody help?
Thanks a lot!
Bart
Reply | Threaded
Open this post in threaded view
|

Re: RECODE LOOP

Maguin, Eugene
Bart,

Bluntly, it doesn't make sense. The recode command is used incorrectly. The
first thing for you to do is to read the documentation in the syntax
reference on the recode command.

That said, I don't understand what you are trying to do. The do if command
doesn't make too much sense  either. Rather than us trying to figure it out,
please give us a description in words of what you want to do.

Gene Maguin



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
jjek
Sent: Friday, April 01, 2011 1:15 PM
To: [hidden email]
Subject: RECODE LOOP

Dear all,

Executing the following syntax:

DATASET ACTIVATE DataSet1.
VECTOR UNIQUE_ID = UNIQUE_ID.1 TO UNIQUE_ID.223.
LOOP #X = 1 TO 223.
DO IF (ANY(UNIQUE_ID(#X),IDFA2010.1 TO IDFA2010.223,IDMO2010.1 TO
IDMO2010.223) = 0).
RECODE UNIQUE_ID(#X) (ELSE=SYSMIS).
END IF.
EXECUTE.
END LOOP.

I receive the error:

>Error # 4631 in column 8.  Text: UNIQUE_ID
>On the RECODE command, the list of variables to be recoded includes the
name
>of a nonexistent variable.
>This command not executed.
END IF.
EXECUTE.

>Warning # 142.  Command name: EXECUTE
>LOOP has no effect on this command.

>Error # 4095.  Command name: EXECUTE
>The transformations program contains an unclosed LOOP, DO IF, or complex
file
>structure.  Use the level-of-control shown to the left of the PASW
Statistics
>commands to determine the range of LOOPs and DO IFs.
>This command not executed.

I cannot figure out why this syntax doesn't work. Can anybody help?
Thanks a lot!
Bart


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/RECODE-LOOP-tp4276243p4276243.
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

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: RECODE LOOP

David Marso
Administrator
In reply to this post by jjek

Reason?
RECODE syntax:
RECODE var (val=#)(val=#)...
Guess:
SPSS parser cannot disambiguate the expectation of the parenthesized lists in RECODE from the Indexed VECTOR .
---
Simple FIX:
Do not use VECTOR for this.  VECTOR is very useful and many times one can't do without it.  
This is NOT one of those situations.



INSTEAD:

DO REPEAT UNIQUE_ID = UNIQUE_ID.1 TO UNIQUE_ID.223.
DO IF ( ANY( UNIQUE_ID,  IDFA2010.1 TO IDFA2010.223, IDMO2010.1 TO IDMO2010.223) = 0).
+  RECODE UNIQUE_ID (ELSE=SYSMIS).
END IF.
END REPEAT.
** THE EXECUTE WAS IN THE WRONG PLACE and you *REALLY* most likely DON'T NEED IT anyway!!!!
** EXECUTE.
----
In the future please describe WHAT your syntax is supposed to achieve.
After some puzzling I 'guess' you want to see if any of the variables IDFAxxx, IDMOxxx blah blah blah
contain the value in the variable you are currently looking at?  If NOT, set the variable to 0.

A more readable version would be
DO REPEAT UNIQUE_ID = UNIQUE_ID.1 TO UNIQUE_ID.223.
IF NOT(ANY(UNIQUE_ID,  IDFA2010.1 TO IDFA2010.223, IDMO2010.1 TO IDMO2010.223) ) UNIQUE_ID=$SYSMIS
END REPEAT.

OTOH:  It is counter to best practices to utilize $SYSMIS in this fashion.
See Art Kendell Soapbox #123-532 (I'll let you google his wisdom in this regard).
<a href="http://spssx-discussion.1045642.n5.nabble.com/plotting-response-gt-0-for-separate-variables-split-by-a-categorical-variable-tt1079972.html#a1079975#none">http://spssx-discussion.1045642.n5.nabble.com/plotting-response-gt-0-for-separate-variables-split-by-a-categorical-variable-tt1079972.html#a1079975#none
(for one example -please note also his reference to = vs EQ).
If you ponder that and this you will be saving yourself a lot of pain and misery in your future SPSS endeavors.

Better practice (NOTE indenting as well-:

MISSING VALUES
              UNIQUE_ID.1 TO UNIQUE_ID.223 (-999999) /* Or some other value you choose */.
ADD VALUE LABELS
              UNIQUE_ID.1 TO UNIQUE_ID.223 -999999 "ZAPPED DUE TO IDFA... IDMO JAZZ".
DO REPEAT
              UNIQUE_ID = UNIQUE_ID.1 TO UNIQUE_ID.223.
+    IF  NOT(ANY(UNIQUE_ID,  IDFA2010.1 TO IDFA2010.223, IDMO2010.1 TO IDMO2010.223) )
              UNIQUE_ID=-999999 .
END REPEAT.





jjek wrote
Dear all,

Executing the following syntax:

DATASET ACTIVATE DataSet1.
VECTOR UNIQUE_ID = UNIQUE_ID.1 TO UNIQUE_ID.223.
LOOP #X = 1 TO 223.
DO IF (ANY(UNIQUE_ID(#X),IDFA2010.1 TO IDFA2010.223,IDMO2010.1 TO IDMO2010.223) = 0).
RECODE UNIQUE_ID(#X) (ELSE=SYSMIS).
END IF.
** THE EXECUTE IS IN THE WRONG PLACE ANYWAYS (it has to be OUTSIDE the LOOP)!!!!
EXECUTE.
END LOOP.

I receive the error:

>Error # 4631 in column 8.  Text: UNIQUE_ID
>On the RECODE command, the list of variables to be recoded includes the name
>of a nonexistent variable.
>This command not executed.
END IF.
EXECUTE.

>Warning # 142.  Command name: EXECUTE
>LOOP has no effect on this command.

>Error # 4095.  Command name: EXECUTE
>The transformations program contains an unclosed LOOP, DO IF, or complex file
>structure.  Use the level-of-control shown to the left of the PASW Statistics
>commands to determine the range of LOOPs and DO IFs.
>This command not executed.

I cannot figure out why this syntax doesn't work. Can anybody help?
Thanks a lot!
Bart
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?"
Reply | Threaded
Open this post in threaded view
|

Re: RECODE LOOP

David Marso
Administrator
In reply to this post by Maguin, Eugene
What's the matter Gene?  Your ESP/Internetelepathy on the fritz ? ;-)))
Basically IF (something doesn't equal any of a whole bunch of other crap) THEN nuke it!
"The first thing for you to do is to read the documentation"
-----------
ROFLMAO:  The last thing people do is read the documentation ;-) .  I used to do Technical support...
User: "I am having a problem doing blah blah blah...."
Me:   "What's it doing?"
User: "It's not doing what it is supposed to.... (LONG description mostly irrelevant shit").
Me:  Hmmmm.  It seems to be doing EXACTLY what it is supposed to be doing..
User: "I beg to differ..."
Me: "Why is that?  Do you have the manual handy?"
User: " MANUAL?? MANUAL?? I don't need no stinkin manual..."
Me: " - <mute button> Ohhhh shit... F'n User of Sierra Madre </mute button>..
       So, how do you know it's not doing what it is supposed to do?
User: "Are you questioning me?"
Me: "YES!!!!"
User:"  I really don't like your attitude.  I want to talk to your supervisor...What's your name?  Put me on with your supervisor.."
Me:"OK, but my supervisor isn't going to answer your question.  So talk with you next time eh? Have a *NICE* DAY <mute> Asshole </mute> "
Me:<mute button on> Dumb ass arrogant MF...</mute button>.. OK, here she is..
User: "GACK... You mean your supervisor is a woman?...>
Me :"Transfer/CLICK... Time for a smoke break.

OTOH:  I left out the RTFM part on my post so thanks for adding that .

Happy April Fools day everyone.

---------

----
Gene Maguin wrote
Bart,

Bluntly, it doesn't make sense. The recode command is used incorrectly. The
first thing for you to do is to read the documentation in the syntax
reference on the recode command.

That said, I don't understand what you are trying to do. The do if command
doesn't make too much sense  either. Rather than us trying to figure it out,
please give us a description in words of what you want to do.

Gene Maguin



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
jjek
Sent: Friday, April 01, 2011 1:15 PM
To: [hidden email]
Subject: RECODE LOOP

Dear all,

Executing the following syntax:

DATASET ACTIVATE DataSet1.
VECTOR UNIQUE_ID = UNIQUE_ID.1 TO UNIQUE_ID.223.
LOOP #X = 1 TO 223.
DO IF (ANY(UNIQUE_ID(#X),IDFA2010.1 TO IDFA2010.223,IDMO2010.1 TO
IDMO2010.223) = 0).
RECODE UNIQUE_ID(#X) (ELSE=SYSMIS).
END IF.
EXECUTE.
END LOOP.

I receive the error:

>Error # 4631 in column 8.  Text: UNIQUE_ID
>On the RECODE command, the list of variables to be recoded includes the
name
>of a nonexistent variable.
>This command not executed.
END IF.
EXECUTE.

>Warning # 142.  Command name: EXECUTE
>LOOP has no effect on this command.

>Error # 4095.  Command name: EXECUTE
>The transformations program contains an unclosed LOOP, DO IF, or complex
file
>structure.  Use the level-of-control shown to the left of the PASW
Statistics
>commands to determine the range of LOOPs and DO IFs.
>This command not executed.

I cannot figure out why this syntax doesn't work. Can anybody help?
Thanks a lot!
Bart


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/RECODE-LOOP-tp4276243p4276243.
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

=====================
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
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?"