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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.