Stata Recode
The recode command replaces values of a variable.
Contents
Usage
recode foo (0=.) recode foo (0=.), generate(bar) recode foo (0=.) if foo!=., generate(bar) recode foo (0=.) in 1/10, generate(bar)
Numeric lists are valid on the left side of an instruction.
recode foo (0 9=.)
In the context of the recode command, numeric ranges are inclusive and capture non-integers.
recode foo (1/2=0) (3/5=1), generate(baz)
The min and max keywords dynamically capture the lowest and highest non-missing values.
The following keywords can be used to capture values that fall through preceding rules:
nonmissing
missing
else
If creating a new variable, the missing value is set for all rows that were filtered out of the recode command (by either if or in). To instead copy the source variable's value for these rows, use the copyrest option.