Hi,
You can perhaps give the following a go.
I split the code to make reading and debugging easier. i think the same could have been accomplished with the datastep.
proc sql; /*Get the duplicate counts*/ create table t1 as select id,pam,seq,val,ord,1 as flg from have group by id,pam,seq,val,ord having count(*)>1 ;
/*From with in the duplicates get the mmaximum value, excluding the minimum values this should allow for other values to also be excluded*/ create table t2 as select a.id,a.pam,a.seq,a.val, max(a.ord) as maxord from t1 a left outer join (select id,pam,seq,val, min(ord) as minord from t1) b on (a.id=b.id & a.pam=b.pam & a.seq=b.seq & a.val=b.val & a.ord ne b.minord) group by a.id,a.pam,a.seq,a.val ;
/*Using the new data flag the OBS that are duplicates*/ create table want2 as select a.*,b.flg from have as a left join(select id,pam,seq,val,maxord, 1 as flg from t2) as b on (a.id=b.id & a.pam=b.pam & a.seq=b.seq & a.val=b.val & a.ord=b.maxord ); quit;
Hope this can at least provide some guidance.
KR
H
... View more