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 (November 2011)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 23 Nov 2011 17:58:50 -0800
Reply-To:     Bruce Weaver <bruce.weaver@hotmail.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Bruce Weaver <bruce.weaver@hotmail.com>
Subject:      Re: Syntax for creating a string variable out of the last 6
              digits of another string variable
In-Reply-To:  <CAH4R4DQitYTy+Zw8FtVm_Wy3+MeejZfiU7-jJbtpcuGEnfi0uQ@mail.gmail.com>
Content-Type: text/plain; charset=us-ascii

Look up examples for STRING (to declare the new string variable), LENGTH (to obtain the length of the original string variable), and SUBSTR (to extract the last 6 digits). I don't have SPSS on this machine, but I think something like this (untested) will work:

STRING UniqueID (A6). COMPUTE #D1 = LENGTH(YourStringVar) - 5. /* position of first digit . IF #D1 GE 1 UniqueID = SUBSTR(YourStringVar,#D1,6). EXECUTE.

HTH.

Nancy Rusinak wrote > > Hello - have a string variable with data of differing lengths in it. > However, the last 6-digits are a unique identifier. I'd like to create > a > separate string variable with only those 6 digits. Anyone know some > syntax > for this? I'm sure it is an easy fix! Can't seem to use strung or concat > functions as the data are different lengths. Example below. Many thanks! > Nancy > > Jones, Bob~bvm312 > Roberts, Samuel~ccm546 > Smith, Ramona~bnd567 >

----- -- Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.

-- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Syntax-for-creating-a-string-variable-out-of-the-last-6-digits-of-another-string-variable-tp5018788p5019029.html Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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