^recode2^

^recode2^ is a frontend for the @recode@ command. It allows a varlist and can recode into a list of new variables. It is also compatible with the syntax of the SPSS recode command.

^Syntax^

^recode2^ varlist [:] rules [ > newvarlist ]

The rules have the same syntax as @recode@. Optionally, elements may be placed in parentheses and commas may be placed within number lists for greater readablility.

If more than one variable is specified in the ^varlist^, then the ^varlist^ must be delimited by a colon ":". If the rules are placed in parentheses then these will act as the delimiter and a colon is optional. delimit the varlist. If no colon or opening parentheses is found then the first word of the ^recode2 > ^ input string is treated as the varname.

Following the rules, a ">" may be placed followed by a list of new variable names into which the variables are to be recoded. The newvarlist must consist of new variables only. Each variable from the input varlist is copied to its counterpart in the newvarlist, then recoded. Note that this implies the "(else=copy)" option of the SPSS recode command.

^recode2^ transforms SPSS keywords into their Stata counterparts, then passes the results to Stata's @recode@ command. The following transformations are applied to the input string:

" to " "-" " into " ">" "lo" "min" "lowest" "min" "hi" "max" "highest" "max" "else" "*" "missing" "." "sysmis" "." " thru " "/" "," " " "(" " " ")" " "

^Examples^

recode2 x 1 3/5=6 2 8=3 *=1 recode2 x (1,3 thru 5=6) (2,8=3) (else=1) recode2 x y z : 1 3/5=6 2 8=3 *=1 > v1-v3 recode2 x y z (1,3/5=6) (2,8=3) (*=1) into v1 to v3 * this will work recode2 x y z (1 3/5=6 2 8=3 *=1 > v1-v3 * this won't, y and z will be treated as rules. recode2 x y z 1 3/5=6 2 8=3 *=1 > v1-v3

-------- John Hendrickx <J.Hendrickx@@mailbox.kun.nl> Nijmegen Business School, University of Nijmegen, The Netherlands