Wednesday 23 November 2016

SAS Merge Statement - Combining Datasets

2.   MERGING :
Merging is nothing but combining two or more SAS datasets horizontally
In one to one merging dataset are not required to be sorted
But for match merging sorted data sets are mandatory.
We can use MERGE statement for this.

Two types of merging can be done
a. One to One Merge
b. Match Merge

While merging data sets SAS writes one new observation for each observation in the data set with the largest number of observation in the by group.
In match merging if the relation is one to many we get different results than what we would get with sql join. This has been illustrated with following example.







SAS MERGE code requires that input datasets must be already sorted with variables listed in BY statement. However PROC SQL dont need this; and thus being advantageous.
 
But as we can see below there is significant difference between the outputs produced by these methods. So one must take precautions while using MERGE statement with many to many relationship.



Happy Coding......

ref URL: https://sites.google.com/site/sasbuddy/sas-merge-statement


11 comments:

  1. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    Best Python Training Institute in Bangalore

    ReplyDelete
  2. First of all Big thanks for sharing this with us. Excellent content with a cool idea, the great content of various kinds of the valuable information.

    Selenium Training in Chennai
    selenium Classes in chennai
    iOS Training in Chennai
    Digital Marketing Training in Chennai
    SEO Course in Adyar
    SEO Course in Velachery

    ReplyDelete