I would like to merge three datasets A, B, and C to find all the obs in A that do not match B and C. B and C are both subsets of A. Obs in B and C do not match each other.
I have tried the code below and many other logic test, but I cannot seem to get the right output. Any help would be appreciated.
data want;
merge A(in= inA) B(in=inB) C(in=inC);
by id date;
if not inA or (not inB and not inC) then
output want;
run;
So you want to keep all records in A that don't find matches in either B or C?
I would suggest this code:
data want;
merge a(in=inA) b(in=inB) c(in=inC);
by id date;
if inA and not inB and not inC;
run;
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.