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;

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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