=========================================================================
Date: Fri, 7 Jul 2006 13:54:56 -0500
Reply-To: "Oliver, Richard" <roliver@SPSS.COM>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Oliver, Richard" <roliver@SPSS.COM>
Subject: Re: Truncating zip code
Content-Type: text/plain; charset="US-ASCII"
This solution is a tad more complex than it needs to be. Specifically, the COMPUTE statement can be simplified to:
compute zip_five=zip.
This will result in a truncated string if zip_five is defined as A5 (as in your example).
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Mahbub Khandoker
Sent: Friday, July 07, 2006 1:43 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Re: Truncating zip code
HI Allen,
You can try this,
data list list / ZIP(a9).
begin data.
064513330
075101210
123456789
end data.
STRING ZIP_five(A5).
COMPUTE ZIP_five=RTRIM(SUBSTR(ZIP,INDEX(ZIP,',')+1)).
EXECUTE.
Cheers!
Mahbub
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Frommelt, Allen
Sent: 7-Jul-06 2:28 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: Truncating zip code
I am interested in mapping patient origin from zip code. Our zip codes are currently 9 character strings, but our mapping software can only read five character zip codes. Does anyone on the list know of a method in SPSS that will allow me to create a 5 character zip code variable by lopping off the last four characters (e.g., 06451333 would become 06451).
Thanks
|