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 |
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.