下面的程序,是我用来生成行业虚拟变量的。但是为啥,为啥生成的变量中取值是1和.(missing ),而不是0.请各位大侠帮忙查下哪里有问题。拜托啦~~
data a;input n r sic value date ddmmyy8.;
format date ddmmyy10.;
cards;
1 0.1 1 109 01-12-10
2 0.2 1 209 01-12-10
3 0.3 1 167 01-12-10
4 0.1 2 123 01-12-10
5 0.2 2 200 01-12-10
6 0.3 2 210 01-12-10
7 0.4 2 342 02-12-10
8 0.12 1 223 02-12-10
1 0.29 1 560 02-12-10
;
run;
proc sql noprint;
select distinct sic into: values separated by ' '
from a
where not missing(sic);
%let n=&sqlobs.;
quit;
%macro create_dumy;
data b;
set a;
select(sic);
%do i=1 %to &n.;
%let val = %scan(&values.,&i);
when( "&val.") dumy_&i =1;
%end;
otherwise put '0';
end;
run;
%mend;
%create_dumy