data dat;
input id $ year qtr;
datalines;
张生 1999 4
张生 2000 1
张生 2000 2
张生 2000 3
张生 2000 4
张生 2001 1
张生 2001 2
张生 2001 3
张生 2001 4
张生 2002 1
张生 2002 2
张生 2002 3
张生 2002 4
张生 2003 1
张生 2003 2
张生 2003 3
张生 2003 4
张生 2004 1
张生 2004 2
张生 2004 3
张生 2004 4
;
run;
proc sql;
create table res as
select *,year+0.1*qtr as mark,case when max(year)-3>min(year) then 1 else 0 end as flag from dat
group by id order by id,year,qtr;
create table b as
select id,year,qtr from res having mark=min(mark)
union
select id,year,qtr from res having flag=1 and mark=max(mark)-3;
quit;
这样能不能满足要求********************************************************************************
意思理解错误,正确解法请看10楼 @Tigflanker


雷达卡




京公网安备 11010802022788号







