Here's another option data have; input group a $ b c; datalines; 1 A 23 20 1 B 34 32 1 C 29 12 1 D 24 10 2 E 45 65 2 F 87 25 2 G 89 76 ; run; proc sort data=have; by descending group descending a ; run; data want; set have; by descending group descending a; retain icount; if first.group then icount=0; if icount<2 then do; output; icount++1; end; drop icount; run; proc sort data=want; by group a; run;
... View more