LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2010)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 26 Apr 2010 11:34:13 -0400
Reply-To:     Gene Maguin <emaguin@buffalo.edu>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Gene Maguin <emaguin@buffalo.edu>
Subject:      Re: Syntax not working
In-Reply-To:  <5AB66E3A87B709438143813E78A72DCC1527F120@excnysm95banp.nysemail.nyenet>
Content-Type: text/plain; charset="us-ascii"

The problem is in the Do if statement, thats what the error message says. I think you should be using the Any function. I understand what your colleague means but spss won't because there is no In function in spss. Look at the Any and Range functions in the sytax reference (page 114 in V17). This is untested but this is what I'd start with and see what happens.

Do if (any(char.substr(char.LPAD(NYSID,9),9),"1","2","3","4","5","6","7","8","9"," 0")).

Improvements (assuming I understand your data structure). First, I think you may be able to use Range instead of Any where the low value is '0' and the high value is '9'. Note the little note about 'national collating sequence' in the syntax ref and which is undefined (and with no reference to it).

Second, as I understand your data, the value is either going to be '123456789' or '12345678A'. If so, then this will work:

Do if (any(char.substr(NYSID,1,9),"1","2","3","4","5","6","7","8","9","0")).

Actually, if your data are right justified so that the left characters are blanks if the NYSID is less than 9 chars, the Lpad is also not needed.

Gene Maguin

PS. I don't think the Lpad is needed at all in any of the compute statements.

>>Good morning. For the last few days I've been trying to figure out why the syntax below does not work. My colleague wrote the syntax to do the following "Translated this means if the last (9th) character of a right justified left padded variable is numeric then take the first 9 characters else

Take the first eight characters." Typically we use an identifier variable (NYSID) that includes 8 numeric digits and the last is an alpha (e.g 23882939L). It's much easier to drop the alpha digit and work with a numeric number. However, it's possible that the identifier can vary in length as well as not include the last alpha (agencies forget). My friend wrote the syntax below to account for all this.but I keep getting the following error (see below). Any suggestions would be greatly appreciated. Thanks, A

DO IF char.substr(char.LPAD(NYSID,9),9) in ("1","2","3","4","5","6","7","8","9","0")

COMPUTE VAR00005=char.substr(CHAR.LPAD(NYSID,1,9))

else

COMPUTE VAR00005=char.substr(CHAR.LPAD(NYSID,1,8))

End if.

Error # 4205. Command name: DO IF

The syntax calls for a logical expression but a numeric or character

expression was found.

This command not executed.

P Please consider the environment before printing this e-mail.

________________________________

This e-mail, including any attachments, may be confidential, privileged or otherwise legally protected. It is intended only for the addressee. If you received this e-mail in error or from someone who was not authorized to send it to you, do not disseminate, copy or otherwise use this e-mail or its attachments. Please notify the sender immediately by reply e-mail and delete the e-mail from your system.

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (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


Back to: Top of message | Previous page | Main SPSSX-L page