As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

Joining Data: Data Step Merge or SQL?

From sasCommunity
Revision as of 09:34, 28 September 2017 by Paulkaefer (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Harry Droogendyk, Stratia Consulting Inc., Lynden, ON
Faisal Dosani, RBC Royal Bank, Toronto, ON


This paper explores the joining of datasets / tables using both the data step MERGE and PROC SQL. Similarities between the two methods are identified and occasions when one method might be preferred over the other are discussed. Specific issues relating to INNER, OUTER and FULL joins are covered, as are the vagaries of the SQL ON vs. WHERE clauses. An array of examples will illustrate exactly how joins are accomplished in both data step and SQL environments. Included in the presentation is a method of displaying SQL's inner workings providing hints for query optimization.

Online resources

See also


  • Lafler, Kirk. 2002. "A Visual Introduction to SQL Joins" The Twenty-Seventh Annual SAS® Users Group International Conference Proceedings, Orlando, FL. (June 22, 2007).
  • Raithel, Michael A. 2005. "The Basics of Using SAS® Indexes" Proceedings of the Thirtieth Annual SAS® Users Group International Conference, Philadelphia, PA. (January 2, 2008).