Date: Wed, 23 Nov 2011 17:58:50 -0800
Reply-To: Bruce Weaver <firstname.lastname@example.org>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Bruce Weaver <email@example.com>
Subject: Re: Syntax for creating a string variable out of the last 6
digits of another string variable
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).
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
> separate string variable with only those 6 digits. Anyone know some
> 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!
> Jones, Bob~bvm312
> Roberts, Samuel~ccm546
> Smith, Ramona~bnd567
"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
For a list of commands to manage subscriptions, send the command