data a;
input id $ date x $;
datalines;
a1 1 x1
a1 3 x2
a1 5 x5
a2 1 y1
a2 2 y2
a2 3 y3
a2 4 y4
a2 5 y5
a3 2 z1
a3 3 z2
a3 4 z3
;
run;
proc sql;
create table b as
select id, min(date) as date_min, max(date) as date_max, count(*) as total
from a
group by id
having date_min=1 and date_max=5 and total=5;
select a.*
from a,b
where a.id=b.id;
quit;
所以我认为满足你需要的应该是下面这样的
proc sql;create table b as
select * from a group by id having count(date)=count(distinct(date))=5 and date in(1,2,3,4,5)order by date;
create table final as select * from b group by id having count(date)=5 order by date;quit;