duplicates drop

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 122
Accepted Solution

duplicates drop

Hi,

I try to drop duplicate observations by some variables. Please help me with both data procedure and sql procedure.

My dataset has variables

y     x1     x2     x3     x4

I want to delete duplicates by y, x1 and x2. If y, x1 and x2 are the same in two observations, the two observations are treated duplicated and I want to only keep one. I tried nodupkey in proc sort procedure, but it will not work because x3 and x4 are different in the two observations. How to use proc sql and/or proc sort to drop duplicates?

THanks.


Accepted Solutions
Solution
‎07-18-2013 04:23 AM
Occasional Contributor
Posts: 13

Re: duplicates drop

Hi Seanz

Try this

proc sort data=have out=want nodupkey;

by y x1 x2;

run;

View solution in original post


All Replies
Solution
‎07-18-2013 04:23 AM
Occasional Contributor
Posts: 13

Re: duplicates drop

Hi Seanz

Try this

proc sort data=have out=want nodupkey;

by y x1 x2;

run;

Frequent Contributor
Posts: 81

Re: duplicates drop

grt ans DJ

Occasional Contributor
Posts: 13

Re: duplicates drop

Thanks to all

Frequent Contributor
Posts: 122

Re: duplicates drop

Perfect! Thanks.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 254 views
  • 0 likes
  • 3 in conversation