增加一个辅助变量,用SQL的连接查询
proc sort data=a09 out=a09sort;
by code;
run;
data a09sort;
set a09sort;
by code;
if first.code then id=1;
else id+1;
run;
data rf;
set rf;
id=_n_;
run;
proc sql;
create table result as select * from rf a,a09sort b where a.id=b.id;
quit;
data result;
set result;
drop id;
run;