Introduction

When you need to select data from multiple tables and combine the tables horizontally (side by side), PROC SQL can be an efficient alternative to other SAS procedures or the DATA step. You can use a PROC SQL join to combine tables horizontally:

Diagram of two tables joined horizontally
proc sql;
   select *
      from a, b
      where a.x=b.x;

A PROC SQL join is a query that specifies multiple tables and/or views to be combined and, typically, specifies the conditions on which rows are matched and returned in the result set.

You should already be familiar with the basics of using PROC SQL to join tables. In this lesson, you will take a more in-depth look at joining tables.

 

2.5 hours



In this lesson, you learn to

  • combine tables horizontally to produce a Cartesian product
  • combine tables horizontally using inner and outer joins
  • use a table alias in a PROC SQL query
  • use an in-line view in a PROC SQL query
  • compare PROC SQL joins with DATA step match-merges and other SAS techniques
  • use the COALESCE function to overlay columns in PROC SQL joins.

complete the following lessons:

  • .