你看是这个意思吗?但是只有 5个dummy变量啊
data want;
infile 'C:\360Downloads\quest1.csv' missover dsd firstobs=2;
input id : $10. year sqtile shrcrl;
run;
proc sort data=want out=aa;
by year sqtile;
run;
proc means data=aa noprint;
by year sqtile;
var shrcrl;
output out=work.b(drop= _type_ _freq_) median=med_shr;
run;
data union;
merge aa(in=a) b(in=b);
by year sqtile;
run;
%macro change;
%do j=2008 %to 2014;
data final;
set union;
where year = &j.;
run;
proc sql noprint;
select med_shr into :macro1-:macro5 from work.b
where year=&j.;
quit;
run;
data aaa;
set final;
%do i=1 %to 5;
if shrcrl < &¯o&i. then d&i.=1;
else d&i.=0;
%end;
run;