Chapter Contents

Previous

Next
The SQL Procedure

Example 4: Joining Two Tables


Procedure features:
FROM clause
table alias
inner join
joined-table component
PROC SQL statement option
NUMBER
WHERE clause
IN condition
Tables: PROCLIB.STAFF, PROCLIB.PAYROLL

This example joins two tables in order to to get more information about data that are common to both tables.



Input Tables
PROCLIB.STAFF (Partial Listing) [HTML Output]
 [Listing Output]
PROCLIB.PAYROLL (Partial Listing) [HTML Output]
 [Listing Output]


Program

libname proclib 'SAS-data-library';
options nodate pageno=1 linesize=120 pagesize=40;
 Note about code
proc sql number;
 Note about code
    title 'Information for Certain Employees Only';
    select Lname, Fname, City, State,
           IdNumber, Salary, Jobcode



 Note about code
       from proclib.staff, proclib.payroll



 Note about code
       where idnumber=idnum and idnum in 
              ('1919','1400', '1350', '1333');


Output
[HTML Output]  [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.