Hi ,
I merged two datasets using the code below. How do I export or output the IDs and observations in "LOS2" dataset that were not merged into "four" dataset?
data five;
merge four (in=a) LOS2 (keep = ID Admission_date Discharge_date LOS Discharge);
by ID;
if a = 1;
run;
Thank you in advance!
data five;
merge four (in=a)
LOS2 (in = b keep = ID Admission_date Discharge_date LOS Discharge);
by ID;
if b and not a;
run;
data five other; merge four (in=a) LOS2 (keep = ID Admission_date Discharge_date LOS Discharge); by ID; if a = 1 then output five; else output other; run;
You need to 1) specify another data set on the Data statement, 2) conditionally indicate which specific data set using OUTPUT statements which data set each group of records gets written to.
data five;
merge four (in=a)
LOS2 (in = b keep = ID Admission_date Discharge_date LOS Discharge);
by ID;
if b and not a;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.