BookmarkSubscribeRSS Feed
PhanS
Obsidian | Level 7

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;

 

 

4 REPLIES 4
Reeza
Super User

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;

 

 


 

PhanS
Obsidian | Level 7

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

Reeza
Super User

Look at PROC SORT with the DUPOUT or NOUNIQUERECS options. 

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

PhanS
Obsidian | Level 7

Thank you. I will try.

 

Phan S.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 975 views
  • 0 likes
  • 2 in conversation