BookmarkSubscribeRSS Feed
excite141
Calcite | Level 5

I have the following data set: 

 

IdDOBType
111/5/1998Second
226/8/1987Third
335/3/2012Fourth
336/10/1945First
223/2/1986Fifth
441/1/1992

First

 

I need to pull the duplicates by ID and DOB. 

 

I need the following data to be made: 

 

IdDOBType
226/8/1987Third
223/2/1986Fifth
335/3/2012Fourth
336/10/1945First

 

Can you please help?

4 REPLIES 4
novinosrin
Tourmaline | Level 20
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

excite141
Calcite | Level 5

I apologize. I do need it to have the result I stated.

Same IDs attached to different DOBs. 

novinosrin
Tourmaline | Level 20

No worries and thanks. The above code should work for your requirement.

novinosrin
Tourmaline | Level 20

Or just with proc sort

 

 PROC SORT DATA=have OUT=want NOUNIQUEKEY; 
   BY id;
 RUN;

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1560 views
  • 2 likes
  • 2 in conversation