Hi, I have this piece of code below:
data data3;
merge data1(in=a) data2(in=b);
by id
if a or b;
run;
When I read this code, I am the impression that this will be like a full outer join. However, when I run this program, it becomes more of a union than a full outer join. Please keep in mind that data1 has 2 columns, including the ID and date while data2 has 3 - ID, date and description.
I want to understand as to why data3 resulted into a union rather than a full outer join. Is there a specific instance where it will be a full outer join than a union?
Any insight will be helpful. Thanks!
Thank you! I think I understand this now!
Your example is a match-merge, which is a limited version of a full outer join, not a union. The MERGE statement can only join one-to-many distinct values of the BY variable. If there are repeats in BY values in both the first and second datasets, only the repeats from the first dataset are kept.
Thank you! I think I understand this now!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.