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.

Example<br />

RECODE 1337<br />

• Variable QVAR is also recoded: original values 1 through 5 are changed to 1; 6 through<br />

10 are changed to 2; 11 through the highest value in the data are changed to 3; and any<br />

other value, including system-missing, is changed to 0.<br />

RECODE STRNGVAR (’A’,’B’,’C’=’A’)(’D’,’E’,’F’=’B’)(ELSE=’ ’).<br />

RECODE PET (’IGUANA’, ’SNAKE ’ = ’WILD ’).<br />

• Values A, B, and C are changed to value A. Values D, E, and F are changed to value B.<br />

All other values are changed to a blank.<br />

• Values IGUANA and SNAKE are changed to value WILD. The defined width of variable<br />

PET is 6. Thus, values SNAKE and WILD include trailing blanks for a total of six characters.<br />

If blanks are not specified, the values are right-padded. In this example, the results<br />

will be the same.<br />

• Each string value is enclosed within apostrophes.<br />

INTO Keyword<br />

INTO specifies a target variable to receive recoded values from the original, or source, variable.<br />

Source variables remain unchanged after the recode.<br />

• INTO must follow the value specifications for the source variables that are being recoded<br />

into the target variables.<br />

• The number of target variables must equal the number of source variables.<br />

Numeric Variables<br />

• Target variables can be existing or new variables. For existing variables, cases with<br />

values not mentioned in the value specifications are not changed. For new variables, cases<br />

with values not mentioned are assigned the system-missing value.<br />

• New numeric variables have default print and write formats of F8.2 (or the format specified<br />

on SET FORMAT).<br />

Example<br />

RECODE AGE (MISSING=9) (18 THRU HI=1) (0 THRU 18=0) INTO VOTER.<br />

• The recoded AGE values are stored in target variable VOTER, leaving AGE unchanged.<br />

• Value 18 and higher values are changed to value 1. Values between 0 and 18, but not<br />

including 18, are recoded to 0. If the specification 0 THRU 18 preceded the specification<br />

18 THRU HI, value 18 would be recoded to 0.<br />

Example<br />

RECODE V1 TO V3 (0=1) (1=0) (2=-1) INTO DEFENSE WELFARE HEALTH.

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

Saved successfully!

Ooh no, something went wrong!