DATA Step, Macro, Functions and more

Deleting the duplicate observations for unique ID

Reply
Contributor
Posts: 44

Deleting the duplicate observations for unique ID

Hello Everyone,

 

I have a sample dataset as shown below. Each ID has different dates. I want to get an output which satisfies two conditions. 

 

1. Keeping only the IDs which have atleast two dates.

2. Deleting the dulpicate dates for each ID. 

 

 

DateID
10/22/20141
10/22/20141
4/23/20141
5/25/20141
4/25/20142
10/22/20143
4/23/20143
4/25/20144
3/4/20144
5/5/20144
5/23/20145
5/25/20146
5/25/20146
5/25/20146
6/24/20146
6/25/20146
6/24/20146
5/8/20147
6/28/20148
6/28/20148
5/24/20149
5/24/20149
8/26/20149
8/26/20149

 

So, when the above conditions are met, My output should look like below. 

 

DateID
10/22/20141
4/23/20141
5/25/20141
10/22/20143
4/23/20143
4/25/20144
3/4/20144
5/5/20144
5/25/20146
6/24/20146
6/25/20146
5/24/20149
8/26/20149

 

Please guide me in coding this. 

 

Thank you

Super User
Posts: 19,768

Re: Deleting the duplicate observations for unique ID

Posted in reply to danwarags

Look at proc sort 

For 1 you need NOUNIQRECS option

For 2 you need NODUPKEY option. 

 

You on should probably apply your second criteria first. 

 

 

Ask a Question
Discussion stats
  • 1 reply
  • 173 views
  • 1 like
  • 2 in conversation