DATA Step, Macro, Functions and more

Find/search ID/Douplicates

Reply
Frequent Contributor
Posts: 83

Find/search ID/Douplicates

Hello,

 

Anyone can help much appreciated. How can I know whether if a duplicate of my sub_IDs that they are not the same. Example 

DATA have;
 INPUT
 sub_id : $6.
 gender : $1.
 dob : DATE9.
 race : $1.
 education : $1.;
 FORMAT dob DATE9.;
 LABEL
 sub_id = "id of a subject"
 gender = "gender"
 dob = "dob"
 race = "race"
 education = "level od education" ;
 DATALINES;
002039 F 27mar1971 1 G
001204 M 12jan1972 1 H
005023 M 15jun1969 2 C
003025 M 17apr1968 2 G
001204 M 23feb1972 1 H
003029 F 30dec1970 1 G
001106 F 25oct1973 2 C
002034 M 31jan1962 3 H
005003 M 15jun1969 2 C
001204 M 01jan1972 1 H
006101 F 08jul1970 2 C
;


proc print data = have;
run;

 

 

Super User
Posts: 22,875

Re: Find/search ID/Douplicates

What's your expected output from this data? I'm assuming that's sample input data.

 


PhanS wrote:

Hello,

 

Anyone can help much appreciated. How can I know whether if a duplicate of my sub_IDs that they are not the same. Example 

DATA have;
 INPUT
 sub_id : $6.
 gender : $1.
 dob : DATE9.
 race : $1.
 education : $1.;
 FORMAT dob DATE9.;
 LABEL
 sub_id = "id of a subject"
 gender = "gender"
 dob = "dob"
 race = "race"
 education = "level od education" ;
 DATALINES;
002039 F 27mar1971 1 G
001204 M 12jan1972 1 H
005023 M 15jun1969 2 C
003025 M 17apr1968 2 G
001204 M 23feb1972 1 H
003029 F 30dec1970 1 G
001106 F 25oct1973 2 C
002034 M 31jan1962 3 H
005003 M 15jun1969 2 C
001204 M 01jan1972 1 H
006101 F 08jul1970 2 C
;


proc print data = have;
run;

 

 


 

Frequent Contributor
Posts: 83

Re: Find/search ID/Douplicates

I want to identify if there are duplicates among subjects. Sub_IDs 005023 and 005003 are identical. I want to find these two subjects.  

Super User
Posts: 22,875

Re: Find/search ID/Douplicates

Look at PROC SORT with the DUPOUT or NOUNIQUERECS options. 

Use the other variables, not ID, in your BY statement. 

Frequent Contributor
Posts: 83

Re: Find/search ID/Douplicates

Thank you. I will try.

 

Phan S.

Ask a Question
Discussion stats
  • 4 replies
  • 103 views
  • 0 likes
  • 2 in conversation