BookmarkSubscribeRSS Feed
RobertHuey
Calcite | Level 5

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!

2 REPLIES 2
DBailey
Lapis Lazuli | Level 10

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);

quit;

Ksharp
Super User

data unique;

set have;

by id;

if first.id and last.id ;

run;

and why can't use sql ?

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

Xia Keshan

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 729 views
  • 0 likes
  • 3 in conversation