Hi @SAS_Muggle , Assuming my understanding of your requirement is correct, methinks your question presents a neat use case for Hash suminc method. Of course, Hash requires significant RAM, nevertheless should be quick.
data Have;
input ID $ Type $;
datalines;
1 A
1 A
1 B
1 B
1 A
1 A
1 A
1 C
1 C
2 A
;
run;
data want ;
retain _iorc_ 1 ;
if _n_=1 then do;
dcl hash h (suminc:'_iorc_') ;
h.definekey('id','type' ) ;
h.definedone( );
end ;
set have ;
h.ref ( ) ;
h.sum (sum : _count) ;
if _count > 2 then flag = '*' ;
drop _: ;
run ;
... View more