|Date: ||Wed, 24 Dec 2008 15:24:25 -0500|
|Reply-To: ||necia <black@BUFFALO.EDU>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||necia <black@BUFFALO.EDU>|
|Organization: ||The University at Buffalo|
|Subject: ||Re: recode|
|Content-Type: ||TEXT/PLAIN; charset=US-ASCII; format=flowed|
Use Autorecode. That is precisely what it is for.
AUTORECODE Variables=V1 to V1 / INTO N1 to N10.
or any other list of variables you have, into an equal nu8mber of new
variables. It will done alphabetically so I don't know if numbers come
first or last but they get recoded too. One of the handiest
transformations SPSS has ever given us. Use it all the time.
If you are using windows I believe you will find AUTORECODE under
"Transform", then follow the dialog box.
Necia A. Black, Ph.D. e-mail: firstname.lastname@example.org
246 Computing Center Web URL:http://www.acsu.buffalo.edu/~black
Buffalo, New York 14260
On Fri, 5 Dec 2008, Joe Matise wrote:
> In the event that it is not as simple as A=1 etc. (in which case I very much
> like karma's index solution), I see no reason why a select when statement
> would not be precisely what you need.
> select (var1);
> when ('A') var2=1;
> when ('B') var2=2;
> otherwise var2 = .;
> which has the advantage of working on character strings greater than one in
> On Fri, Dec 5, 2008 at 9:23 AM, Scott Raynaud
>> Say I have character variable VAR1 that takes on values A, B, C, etc. that
>> I wish to recode into numeric VAR2 where A=1, B=2, C=3 and so on. Is
>> there a more compact way of recoding this other than using a block of
>> if/then statements? I can't use a format statement for this because I
>> will be imputing values to missing data for this variable.