data ex;
input id year leverage $;
cards;
1 1992 a
1 1993 b
1 1995 c
1 1996 d
1 1997 0
1 1998 e
2 1992 a
2 1993 b
2 1994 c
2 1996 d
2 1995 e
2 1997 f
2 1997 a
2 1998 b
2 1999 c
3 1992 a
3 1993 b
3 1994 0
3 1996 e
3 1995 e
3 1997 f
;
run;
proc sort data=ex;
by id year;
run;
data ex1(keep=id);
symbol=1;
count=0;
do until(last.id);
set ex;
by id;
if first.id then continue;
if year-lag(year)=1 and leverage ne "0" then symbol+1;
else symbol=1;
count+(symbol>=5);/*这里测试选择连续存活5年的id,改为10即可*/
if last.id and count>0 then output;
end;
;
run;


雷达卡





京公网安备 11010802022788号







