|
data test;
input id year;
cards;
1 2001
1 2002
1 2004
1 2005
2 2002
2 2003
2 2004
3 2002
3 2005
3 2007
;
run;
proc sort data=test; by id year; run;
data test01;
set test;
by id year;
preyear=lag(year);
if not first.id then do;
dif=year-preyear;
if dif ne 1 then output;
end;
run;
proc sql;
create table test02 as
select *
from test
where cats(put(id,best.), put(year, best.)) in (select cats(put(id,best.), put(year, best.)) from test01)
or cats(put(id,best.), put(year, best.)) in (select cats(put(id,best.), put(preyear, best.)) from test01);
quit;
|