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
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;
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;
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 |
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!
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.