不知道是不是你要的,你看看吧
proc sort data = work.st out = work.a;
by stkcd1 period1;
run;
proc sort data = work.nost out = work.b;
by stkcd2 period2;
run;
proc sql noprint;
create table work.c as
select a.*,
b.*
from work.a as a,work.b as b
where a.period1 = b.period2
and a.stkcd1 ^= b.stkcd2
and a.assets1 / b.assets2 <=0.1;
quit;
proc sort data = work.c;
by stkcd1 period1;
run;
data work.d;
set work.c;
by stkcd1 period1;
if first.stkcd1 then do;
k = 1;
output;
end;else if k<3 then do;
k+1;
output;
end;
run;
|