Saturday, 27 November 2010

RECODE in STATA

recode var names (1 2 = 1 low)  ///
(3 = 2 medium) ///
(4 5 = 3 high) ///
(nonmissing = 9 "something else") ///
(missing = .) ///
, gen(Rx Ry) label(Cat3)

Use mvencode and mvdecode to deal with missing values.
For example to convert 99 into sysmis
in the variable mstatus,

mvdecode mstatus, mv(99)

For the opposite effect,
mvencode mstatus, mv(99)

No comments: