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 20:51:14 +0000
Reply-To:     Ruben van den Berg <>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Ruben van den Berg <>
Subject:      Re: Syntax not working
In-Reply-To:  <5AB66E3A87B709438143813E78A72DCC1527F120@excnysm95banp.nysemail.nyenet>
Content-Type: multipart/alternative;

Dear Adriana, 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. HTH,

Ruben van den Berg Methodologist TNS NIPO E: P: +31 20 522 5738 I: *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 From: Subject: Syntax not working To: SPSSX-L@LISTSERV.UGA.EDU

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.

_________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE!


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