I have the following data set:
| Id | DOB | Type | 
| 11 | 1/5/1998 | Second | 
| 22 | 6/8/1987 | Third | 
| 33 | 5/3/2012 | Fourth | 
| 33 | 6/10/1945 | First | 
| 22 | 3/2/1986 | Fifth | 
| 44 | 1/1/1992 | First | 
I need to pull the duplicates by ID and DOB.
I need the following data to be made:
| Id | DOB | Type | 
| 22 | 6/8/1987 | Third | 
| 22 | 3/2/1986 | Fifth | 
| 33 | 5/3/2012 | Fourth | 
| 33 | 6/10/1945 | First | 
Can you please help?
data have;
input Id	DOB :mmddyy10.	Type $;
format dob mmddyy10.;
cards;
11	1/5/1998	Second
22	6/8/1987	Third
33	5/3/2012	Fourth
33	6/10/1945	First
22	3/2/1986	Fifth
44	1/1/1992	First
;
proc sql;
create table want as
select *
from have
group by id
having count(id)>1;
quit;
I don't think your result appropriates two variables as ID and DOB(different) dobs are not duplicates rather the combination is unique. If the above doesn't meet your requirement, plz clarify
I apologize. I do need it to have the result I stated.
Same IDs attached to different DOBs.
No worries and thanks. The above code should work for your requirement.
Or just with proc sort
 PROC SORT DATA=have OUT=want NOUNIQUEKEY; 
   BY id;
 RUN;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.
