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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.