|
I have some VERY SIMPLE transformation syntax which is generating errors. Granted, I've been away from SPSS for a while, but the following seems like it should work:
=====================
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
COMPUTE Age = $SYSMIS . Instead, I get the following output: > COMPUTE Age = $SYSMIS . |
|
Remove COMPUTE from the IF statement.
Also, COMPUTE AGE=$SYSMIS is unnecessary. For any conditions not specified, it will set to system-missing. Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: Mike Donatello <[hidden email]> To: [hidden email] Date: 05/23/2016 10:46 AM Subject: Need help tracking down simple error Sent by: "SPSSX(r) Discussion" <[hidden email]> I have some VERY SIMPLE transformation syntax which is generating errors. Granted, I've been away from SPSS for a while, but the following seems like it should work: COMPUTE Age = $SYSMIS . DO REPEAT #C = 1 TO 101 . IF (Q2 EQ #C ) COMPUTE Age = #C + 16 . END REPEAT PRINT . Instead, I get the following output: > COMPUTE Age = $SYSMIS . > > DO REPEAT #C = 1 TO 101 . > IF (Q2 EQ #C ) COMPUTE Age = #C + 16 . > END REPEAT PRINT . > > 1142 0 +IF (Q2 EQ 1 ) COMPUTE Age = 1 + 16 > >Error # 4382 in column 35. Text: Age > >An equals sign was not found when expected after a target variable in a > >COMPUTE command. > >Execution of this command stops. > 1143 0 +IF (Q2 EQ 2 ) COMPUTE Age = 2 + 16 > >Error # 4382 in column 37. Text: Age > >An equals sign was not found when expected after a target variable in a > >COMPUTE command. > >Execution of this command stops. > 1144 0 +IF (Q2 EQ 3 ) COMPUTE Age = 3 + 16 > ... Now, I can PLAINLY see the intended equals sign after the target variable (Age). Can anyone spot where I goofed? Thanks, Mike Donatello ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@...(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 |
|
You have to admit that this error message is not well-conceived.
=====================
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
Is COMPUTE a legal name for a variable? If not, then /that/ could be flagged. If it is not 40 years to late to make COMPUTE an optional keyword in the IF command, something should be done to clarify the actual mistake. An error message should at least /state/ the right idea, even if it may be obscure to a newbie. The actual message right now is obscure to everyone who does not make the leap, that an IF statement may be called a COMPUTE statement in an error message. Here is something that is somewhat awkward, but not deceptive -- An equals sign was not found when expected after a target variable "COMPUTE" in the implicit-COMPUTE portion of an IF command. -- Rich Ulrich Date: Mon, 23 May 2016 10:54:08 -0500 From: [hidden email] Subject: Re: Need help tracking down simple error To: [hidden email] Remove COMPUTE from the IF statement. Also, COMPUTE AGE=$SYSMIS is unnecessary. For any conditions not specified, it will set to system-missing. Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: Mike Donatello <[hidden email]> To: [hidden email] Date: 05/23/2016 10:46 AM Subject: Need help tracking down simple error Sent by: "SPSSX(r) Discussion" <[hidden email]> I have some VERY SIMPLE transformation syntax which is generating errors. Granted, I've been away from SPSS for a while, but the following seems like it should work: COMPUTE Age = $SYSMIS . DO REPEAT #C = 1 TO 101 . IF (Q2 EQ #C ) COMPUTE Age = #C + 16 . END REPEAT PRINT . Instead, I get the following output: > COMPUTE Age = $SYSMIS . > > DO REPEAT #C = 1 TO 101 . > IF (Q2 EQ #C ) COMPUTE Age = #C + 16 . > END REPEAT PRINT . > > 1142 0 +IF (Q2 EQ 1 ) COMPUTE Age = 1 + 16 > >Error # 4382 in column 35. Text: Age > >An equals sign was not found when expected after a target variable in a > >COMPUTE command. > >Execution of this command stops. > 1143 0 +IF (Q2 EQ 2 ) COMPUTE Age = 2 + 16 > >Error # 4382 in column 37. Text: Age > >An equals sign was not found when expected after a target variable in a > >COMPUTE command. > >Execution of this command stops. > 1144 0 +IF (Q2 EQ 3 ) COMPUTE Age = 3 + 16 > ... Now, I can PLAINLY see the intended equals sign after the target variable (Age). Can anyone spot where I goofed? Thanks, Mike Donatello ===================== 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 |
|
Compute is a legal variable name. My guess is that the expression parser has stripped off the context of the expression before the error is detected, but I agree that the error message needs work. There are quite a few error messages in the transformation system in that category.
On Monday, May 23, 2016, Rich Ulrich <[hidden email]> wrote:
-- ===================== 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 |
|
FYI, COMPUTE isn't supposed to be a variable name, but I tried the syntax first with the regular IF transformation structure and it gave me the same error. So, I thought maybe something had changed since v14 and I put the COMPUTE statement in there too. It's always the simple stuff that gets you... --- On May 23, 2016 12:57 PM, Jon Peck <[hidden email]> wrote:
=====================
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
Compute is a legal variable name. My guess is that the expression parser has stripped off the context of the expression before the error is detected, but I agree that the error message needs work. There are quite a few error messages in the transformation system in that category. |
|
In reply to this post by Mike Donatello
In order to avoid ever having a user assign sysmis to a variable I changed the first part of the syntax.
I have been after SPSS for decades to give a warning when a user assign sysmis. The snippet below seems to work. data list list/q2 (f3). begin data -1 0 1 5 10 11 end data. COMPUTE Age = -1 . missing values age (-1). value labels age -1 'Q2 not in 1 to 10 range'. DO REPEAT #C = 1 TO 10 . IF (Q2 EQ #C ) Age = #C + 16 . END REPEAT PRINT . list. Might you have something other than a space before the period at eh end of aline.
Art Kendall
Social Research Consultants |
|
Administrator
|
If Q2 takes positive integer values only, then you don't need to loop. I believe the following (untested) will do the same thing as your code:
COMPUTE Age = -1 . IF RANGE(Q2,1,101) Age = Q2 + 16. MISSING VALUES age (-1). VALUE LABELS age -1 'Q2 not in 1 to 101 range'. DESCRIPTIVES Age.
--
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 Art Kendall
Why for crying out loud is this in a loop structure?
Only ONE of these cases can be true. Why not just test it once and get it over with? IF RANGE(Q2,1,10) age =SUM(Q2,16). KISS!!!
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
Thanks, all for the help. Obviously, I need a syntax refresher. --- Mike Donatello, PhD From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Rich Ulrich You have to admit that this error message is not well-conceived. Date: Mon, 23 May 2016 10:54:08 -0500
===================== 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 |
