Hello guys,
I have two datasets A and B. A is a baseline dataset and B is the death dataset.
I want to merge using the "In= " to select only Ids that are in dataset A.
Then also in the merge i want to create a flag using "in=" to determine that the patient died.
My code is attached.
Any help will be appreciated.
data forty;
merge sleep2(in=x) three (in=y);
if in=x then died=y;
run;
proc print; run;
Some code like below should do.
data want;
merge A(in=ina) B (in=inb);
by id;
/* only select rows with an ID in table A */
if ina;
/* set died_flg='Y' if a matching ID in table B */
if inb then
died_flg='Y';
else died_flg='N';
run;
proc print;
run;
data forty;
merge sleep2(in=x) three (in=y);
by id;
if in=x then died=y;
run;
proc print; run;
Some code like below should do.
data want;
merge A(in=ina) B (in=inb);
by id;
/* only select rows with an ID in table A */
if ina;
/* set died_flg='Y' if a matching ID in table B */
if inb then
died_flg='Y';
else died_flg='N';
run;
proc print;
run;
Thanks!
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.