dummy | Macro to create dummy variables | dummy |
FULLRANK=0
)
%dummy(var=sex group,prefix=);
name(s)
of the input variable(s)
to be dummy
coded. Must be specified. The variable(s)
can be character or
numeric.
Prefix(s)
used to create the names of dummy variables. The
default is 'D_'.
NAME=VAL
, the dummy variables are named by appending the value of the VAR= variable to the prefix. Otherwise, the dummy variables are named by
appending numbers, 1, 2, ... to the prefix. The resulting name must be 8
characters or less.
BASE=_FIRST_
specifies that the lowest value of the VAR= variable is the baseline group; BASE=_LAST_
specifies the highest value of the variable. Otherwise, you can specify
BASE=value to make a different value the baseline group.
data test; input y group $ @@; cards; 10 A 12 A 13 A 18 B 19 B 16 C 21 C 19 C ;The macro statement:
%dummy ( data = test, var = group) ;produces two new variables, D_A and D_B. Group C is the baseline category (corresponding to
BASE=_LAST_
)
OBS Y GROUP D_A D_B 1 10 A 1 0 2 12 A 1 0 3 13 A 1 0 4 18 B 0 1 5 19 B 0 1 6 16 C 0 0 7 21 C 0 0 8 19 C 0 0