27.03.2013 Views

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1338 RECODE<br />

• Values for V1 through V3 are recoded and stored in DEFENSE, WELFARE, and HEALTH.<br />

V1, V2, and V3 are not changed.<br />

String Variables<br />

• Target variables must already exist. To create a new string variable, declare the variable<br />

with the STRING command before specifying it on RECODE.<br />

• The new string values cannot be longer than the defined width of the target variable.<br />

• If the new values are shorter than the defined width of the target variable, the values are<br />

right-padded with blanks.<br />

• Multiple target variables are allowed. The target variables must all be the same defined<br />

width; the source variables can have different widths.<br />

• If the source and target variables have different widths, the criterion for the width of the<br />

original values is the width defined for the source variable; the criterion for the width of<br />

the recoded values is the width defined for the target variable.<br />

Example<br />

STRING STATE1 (A2).<br />

RECODE STATE (’IO’=’IA’) (ELSE=COPY) INTO STATE1.<br />

• STRING declares variable STATE1 so that it can be used as a target variable on RECODE.<br />

• RECODE specifies STATE as the source variable and STATE1 as the target variable. The<br />

original value IO is recoded to IA. Keywords ELSE and COPY copy all other state codes<br />

over unchanged. Thus, STATE and STATE1 are identical except for cases with the original<br />

value IO.<br />

Example<br />

RECODE SEX (’M’=1) (’F’=2) INTO NSEX.<br />

• RECODE recodes string variable SEX into numeric variable NSEX. Any value other than<br />

M or F becomes system-missing.<br />

• The program can process a large number of cases more efficiently with the numeric variable<br />

NSEX than it can with the string variable SEX.<br />

CONVERT Keyword<br />

CONVERT recodes the string representation of numbers to their numeric representation.<br />

• If keyword CONVERT precedes the value specifications, cases with numbers are recoded<br />

immediately and blanks are recoded to the system-missing value, even if you specifically<br />

recode blanks into a value.<br />

• To recode blanks to a value other than system-missing or to recode a string value to a<br />

noncorresponding numeric value (for example ‘0’ to 10), you must specify a recode<br />

specification before the keyword CONVERT.<br />

• RECODE converts numbers as if the variable were being reread using the F format.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!