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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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