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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.