RECODE
RECODE changes, rearranges, or consolidates the values of an existing variable.
For numeric variables:
RECODE varlist (value list=newvalue)...(value list=newvalue) [INTO varlist]
[/varlist...]
Input keywords:
LO, LOWEST, HI, HIGHEST, THRU, MISSING, SYSMIS, ELSE
Output keywords:
COPY, SYSMIS
For string variables:
RECODE varlist [('string',['string'...]='newstring')][INTO varlist]
[/varlist...]
Input keywords:
CONVERT, ELSE
Output keyword:`
COPY
This command does not read the active dataset. It is stored, pending execution with the next command that reads the dataset. See the topic Command Order for more information.
Syntax for the RECODE command can be generated from the Recode into Same Variables dialog or the Recode into Different Variables dialog.
Examples
RECODE V1 TO V3 (0=1) (1=0) (2,3=-1) (9=9) (ELSE=SYSMIS).
RECODE STRNGVAR ('A','B','C'='A')('D','E','F'='B')(ELSE=' ').
- The numeric variables between and including V1 and V3 are recoded: original values 0 and 1 are switched respectively to 1 and 0; 2 and 3 are changed to -1; 9 remains 9; and any other value is changed to the system-missing value.
- Values A, B, and C are changed to value A. Values D, E, and F are changed to value B. All other values are changed to a blank.