BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Elaine_Y
Calcite | Level 5

Hi, 

I am joining two datasets by proc sql. 

 

Hi, I hope to remove duplicate ids that contains missing values. The dataset look like below. Thank you very much!

 

id  age  gender outcome_1 outcome_2

1  67       2          .                   .

1  67       2          0                  0

2  55       1          .                   .

2  55       1          1                  1

3  40       2           .                  .

3  40       2           1                  1

1 ACCEPTED SOLUTION

Accepted Solutions
smantha
Lapis Lazuli | Level 10

Hi do you know if you will have multiple ids with missing values or is it always two with one of them missing. If it is the latter you can sort the dataset by id and descending outcome_1. 

proc sort data =inp_data;
by id descending outcome_1;
run;

data inp_data;
set inp_data;
by id;
if first.id;
run;

View solution in original post

3 REPLIES 3
Reeza
Super User
What do you expect as output?
smantha
Lapis Lazuli | Level 10

Hi do you know if you will have multiple ids with missing values or is it always two with one of them missing. If it is the latter you can sort the dataset by id and descending outcome_1. 

proc sort data =inp_data;
by id descending outcome_1;
run;

data inp_data;
set inp_data;
by id;
if first.id;
run;
novinosrin
Tourmaline | Level 20

data have;
input id  age  gender outcome_1 outcome_2;
cards;
1  67       2          .                   .

1  67       2          0                  0

2  55       1          .                   .

2  55       1          1                  1

3  40       2           .                  .

3  40       2           1                  1
;

data want;
 update have(obs=0) have;
 by id age gender;
run;
id age gender outcome_1 outcome_2
1 67 2 0 0
2 55 1 1 1
3 40 2 1 1

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 1002 views
  • 0 likes
  • 4 in conversation