Help using Base SAS procedures

Pulling unique identifiers

Occasional Contributor
Posts: 19

Pulling unique identifiers

Hi all,

Is there a way for me to pull all values in a column that are unique?  I combined two monthly datasets and some of the primary keys are unique when combined, not all of them though.  Is there a way to pull just the unique primary keys without using PROC SQL?  I dropped some of the variables so I can't use PROC SQL according to the log.  Also, I tried using PROC SORT and the NODUPKEY.  I forgot that it keeps one set of the duplicate records but I want to get rid of both sets of the duplicate records.  Let me know of any suggestions!  Thanks!

Super Contributor
Posts: 578

Re: Pulling unique identifiers

So you want to combine two datasets and then delete records that have an id with more than one occurrence?

proc sql;

delete from have

where id in (select id from have group by id having count(*)>1);


Super User
Posts: 9,681

Re: Pulling unique identifiers

data unique;

set have;

by id;

if and ;


and why can't use sql ?

select * from have group by id having count(*)=1  ;

Xia Keshan

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation