BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Vinz867
Fluorite | Level 6

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Vinz867
Fluorite | Level 6

Thank you! I think I understand this now!

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

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.

Vinz867
Fluorite | Level 6

Thank you! I think I understand this now!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 2 replies
  • 662 views
  • 1 like
  • 2 in conversation