/*Creating dummy/indicator variables the easy way*/
Data Code;
Input X Y $ ;
datalines;
15 a
30 a
9 b
6 c
;
run;
/*Method 1: Traditional*/
data Code1;
set Code;
If X>10 then Z1=1;
Else Z1=0;
If 9=<X<=15 then Z2=1;
Else Z2=0;
If Y="a" then Z3=1;
else Z3=0;
run;
/*Method 2: The easy way*/
data Code2;
set Code;
Z1=X>10;
Z2=9<=X<=15;
Z3=Y="a";
run;
No comments:
Post a Comment