A common task when using SAS/STAT procedures is
to recode variable values into dummy variables, that
is, variables that take on a value of either 1 or 0.
The tried and true method is an IF-THEN-ELSE
statement. For example...
if income ge 100000 then dummy_inc = 1;
else dummy_inc = 0;
That method is fine, but if you are recoding a number
if variables, it gets a bit tedious. An alternative is...
dummy_inc = (income ge 100000);
SAS evaluates the expression within the
parentheses. If it is TRUE, the value of the dummy
variable is 1, otherwise it is 0. The expression can
be
compound...
dummy_inc = (income ge 100000 and zip eq 10001);
or...
dummy_inc = (income ge 100000 or cars_owned ge
10);
The compound expression within the parentheses will
either be TRUE or FALSE and the dummy variable will
be 1 or 0.
Note from Daphne and Paul: Thanks to Mike, a
frequent contributor to NESUG, for this great Tech
Note! We will include additional interesting and useful
technical notes from past conferences in future
issues of this newsletter.