Recode Repeating String Values Into New Numeric Variable

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Recode Repeating String Values Into New Numeric Variable

Jim Moffitt
I need to recode about 24,000 values of a string variable into a new and
different numeric variable. Unfortunately, the values of the string
variable are not unique. Some of them repeat. Here's some sample data:
 
DATA LIST FREE / PW (A12).

BEGIN DATA

"A14856XCLB" "B1423CV" "B1423CV" "K12XDF" "Y4218" "Y4218" "P325LLGH"

END DATA

I'd like to recode PW into a new numeric variable named MyPWNum. The
values of this new variable must take into account the fact that some of
the string values in PW are repeated. Thus, the values of MyPWNum for
the sample data listed above should be 1 2 2 3 4 4 5.

Any suggestions? Thanks for your help.
Reply | Threaded
Open this post in threaded view
|

Re: Recode Repeating String Values Into New Numeric Variable

Mike P-5
I think Autorecode is the solution here

AUTORECODE
  VARIABLES=PW  /INTO MyPWNum.

Mike

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Jim Moffitt
Sent: 26 July 2007 17:14
To: [hidden email]
Subject: Recode Repeating String Values Into New Numeric Variable

I need to recode about 24,000 values of a string variable into a new and
different numeric variable. Unfortunately, the values of the string
variable are not unique. Some of them repeat. Here's some sample data:

DATA LIST FREE / PW (A12).

BEGIN DATA

"A14856XCLB" "B1423CV" "B1423CV" "K12XDF" "Y4218" "Y4218" "P325LLGH"

END DATA

I'd like to recode PW into a new numeric variable named MyPWNum. The
values of this new variable must take into account the fact that some of
the string values in PW are repeated. Thus, the values of MyPWNum for
the sample data listed above should be 1 2 2 3 4 4 5.

Any suggestions? Thanks for your help.

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________