Very interesting Question.
data have;
input ID Category $ Score;
datalines;
1 A 100
2 A 95
3 B 80
4 A 75
5 C 70
6 B 65
7 A 60
;
data temp;
set have;
retain A C;
if Category='A' then A=1;
else if Category='C' then C=1;
output;
if A and C then do;call symputx('n',_n_);stop;end;
run;
%macro xx;
%if &n <= 4 %then %do;
data want;
set have;
run;
%end;
%else %do;
data want;
set have(obs=3) have(firstobs=&n);
run;
%end;
%mend;
%xx
... View more