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.
Date | ID |
10/22/2014 | 1 |
10/22/2014 | 1 |
4/23/2014 | 1 |
5/25/2014 | 1 |
4/25/2014 | 2 |
10/22/2014 | 3 |
4/23/2014 | 3 |
4/25/2014 | 4 |
3/4/2014 | 4 |
5/5/2014 | 4 |
5/23/2014 | 5 |
5/25/2014 | 6 |
5/25/2014 | 6 |
5/25/2014 | 6 |
6/24/2014 | 6 |
6/25/2014 | 6 |
6/24/2014 | 6 |
5/8/2014 | 7 |
6/28/2014 | 8 |
6/28/2014 | 8 |
5/24/2014 | 9 |
5/24/2014 | 9 |
8/26/2014 | 9 |
8/26/2014 | 9 |
So, when the above conditions are met, My output should look like below.
Date | ID |
10/22/2014 | 1 |
4/23/2014 | 1 |
5/25/2014 | 1 |
10/22/2014 | 3 |
4/23/2014 | 3 |
4/25/2014 | 4 |
3/4/2014 | 4 |
5/5/2014 | 4 |
5/25/2014 | 6 |
6/24/2014 | 6 |
6/25/2014 | 6 |
5/24/2014 | 9 |
8/26/2014 | 9 |
Please guide me in coding this.
Thank you
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.