backnextLearning Path
   


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.

 

Time to Complete

This lesson contains pages and takes approximately 2.5 hours to complete.



Objectives

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.

Prerequisites

Before taking this lesson, you should complete the following lessons:

  • .

  Copyright © 2003 SAS Institute Inc., Cary, NC, USA. All rights reserved.
Terms of Use & Legal Information | Privacy Statement
backnext