Date: Mon, 26 Apr 2010 20:51:14 +0000
Reply-To: Ruben van den Berg <email@example.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Ruben van den Berg <firstname.lastname@example.org>
Subject: Re: Syntax not working
If the non numeric character is always in the 9th. position, then the two syntax examples below should work. I guess RANGE could be used as well (but I forgot how) as long as you convert the 9th. character to numeric as in the second example.
Ruben van den Berg
P: +31 20 522 5738
*Create test data.
data list free/testvar(a12).begin data23882939L12345678123456789end data.
*Example 1, with ANY.
do if any(sub(testvar,9,1), "1","2","3","4","5","6","7","8","9","0").comp newvar=num(sub(testvar,1,8),f8).else.comp newvar=num(testvar,f8).end if.exe.
*Example 2, any non numeric character will be system missing if converted to numeric.
do if mis(num(sub(testvar,9,1)),f1)=1.comp newvar2=num(sub(testvar,1,8),f8).else.comp newvar2=num(testvar,f8).end if.exe.
Date: Mon, 26 Apr 2010 10:27:36 -0400
Subject: Syntax not working
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")
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.
Express yourself instantly with MSN Messenger! Download today it's FREE!