01-19-2012 08:21 AM
Much has already been written on the topic. A nice intro can be found at: http://www2.sas.com/proceedings/sugi30/249-30.pdf
However, a web search for sas sql merge will bring up quite a few more papers that explain even more of the differences and similarities
02-01-2012 04:46 PM
02-01-2012 05:05 PM
Try the following example. You will discover that the datastep merge will have the same result as a sql join:
input sex $ amount;
proc sort data=second;
merge first second;
However, a many-to-many merge is more difficult to achieve via a datastep merge.
The same thing is true for a datastep merge.
02-07-2012 03:26 AM
#3: what I think Hima meant was that the join variables can be different of you are joining more than two tables. This cannot not be done in one MERGE step.
02-07-2012 09:49 AM
Rename most certainly handles a scenario when your matching columns have different names (but have the same content).
But SQL lets you join multiple tables with differern join criteria in the different "join pairs".
I.e. you can join table A and B on ssn, and table B and C on Zip-code.I think this is not possible in a MERGE step.
02-07-2012 12:00 PM
I feel that the main difference is in Merge, it includes numerous steps to merge the data like Sorting the data firstt by using a BY variable and then merge the data sets horizontallay using the same BY variable. But this is good for small amount of data.
If you have millions of records and u do want the same process then Proc Sql will be the option which saves your time and effort by creating simple code in a single step.
Correct me if i am wrong.
02-07-2012 12:09 PM
SQL processes the entire table in memory. As the size of your tables increase you may experience performance degradation. MERGE processes a row at a time so rarely has memory limitations.