lemonxinran 发表于 2013-3-15 16:38 
谢谢!
It is not easy like proc sql, here I try to use data step
data want;
set have;
by stkcd fyear;
lag_stkcd=lag(stkcd);
lag_fyear=lag(fyear);
retain obsnum;
if first.stkcd then do;
obsnum=0;
end;
if stkcd=lag_stkcd and fyear=lag_fyear then obsnum+1;
else obsnum+1;
if last.stkcd then output;
keep stkcd fyear obsnum;
run;
proc print;
run;