If you consider that a unique ID is one that occurs once only, it is possible to find by using Hash objects. But how much time it will take compared to SQL can be found only by you, by running both ways. Xia has already given a hash solution. It can not tell which ID occurs once only. Here is another hash way with an example, the length of ID need not be 6 in your case. It It collects all records having one ID into one data set(Unique) and the rest to another data set(Duplicates). data have; input ID $6.; datalines; aaaaaa aaaaaa aaaaaa bbbbbb dddddd ; run; data _null_; if _n_ = 1 then do; declare hash h(); h.definekey('ID'); h.definedata('ID','freq'); h.definedone(); end; set have end = eof; if h.find() ne 0 then freq = 0; freq + 1; h.replace(); if eof; h.output(dataset:'Unique (where=(freq=1)'); h.output(dataset:'Duplicates (where=(freq > 1)'); run; proc print data = Unique; run; proc print data = Duplicates; run;
... View more