Chapter Contents

Previous

Next
The SQL Procedure

Example 10: Querying an In-Line View


Procedure features:
FROM clause
in-line view
Tables: PROCLIB.STAFF, PROCLIB.SCHEDULE, PROCLIB.SUPERV

This example uses the query explained in Joining Three Tables as an in-line view. The example also shows how to rename columns with an in-line view.


Program

libname proclib 'SAS-data-library';
options nodate pageno=1 linesize=80 pagesize=60;
 Note about code
proc sql outobs=10;
   title 'All Flights for Each Supervisor';
   select *
 Note about code
      from (select lname, s.idnum, city, jobcat,
                   flight, date
               from proclib.schedule2 s, proclib.staff2 t, 
                    proclib.superv2 v
               where s.idnum=t.idnum and t.idnum=v.supid)










 Note about code
                as three (Surname, Emp_ID, Hometown, 
                           Jobtype, FlightNumber, FlightDate);


Output

                        All Flights for Each Supervisor                        1

                                            Job
  Surname          Emp_ID  Hometown         Category  FlightNumber  FlightDate
  ----------------------------------------------------------------------------
  MARSHBURN        1106    STAMFORD         PT        579              05MAR94
  DENNIS           1118    NEW YORK         PT        132              01MAR94
  DENNIS           1118    NEW YORK         PT        271              04MAR94
  KIMANI           1126    NEW YORK         TA        579              05MAR94
  TUCKER           1882    NEW YORK         ME        622              03MAR94


Chapter Contents

Previous

Next

Top of Page

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