SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Accessing Other Vendors' DBMS Data
Using DBMS Data in SAS Programs


Example 1: Querying a DBMS Table

In this program, the SQL procedure reads flight information from the ORACLE table Delay. The WHERE clause selects only flights to London and Frankfurt. The PROC SQL output is shown below.

     libname oraclib oracle user=cestmoi 
             password=sesame path='oracpath';
     proc sql;
        select dates format=date9., dest 
           from oraclib.delay
           where dest in("FRA","LON")
           order by dest;
     quit;

Dates Dest
01MAR1998 FRA
04MAR1998 FRA
07MAR1998 FRA
03MAR1998 FRA
05MAR1998 FRA
02MAR1998 FRA
04MAR1998 LON
07MAR1998 LON
02MAR1998 LON
06MAR1998 LON
05MAR1998 LON
03MAR1998 LON
01MAR1998 LON


Example 2: Combining DBMS Data and SAS Data

This example shows how to read DBMS data and create an additional variable for calculations or subsets. The program below creates the SAS data set Work.Highwage by reading the DB2 table Payroll (referenced as Db2lib.Payroll). It also creates a variable, Category, based on the value of the Salary column in the DB2 table Payroll. The Payroll table is not modified.

     libname db2lib db2 ssid=db2;
     data highwage;
        set db2lib.payroll(drop=sex birth hired);
        if salary>60000 then
           Category="High";
        else if salary<30000 then
             Category="Low";
        else Category="Avg";
     run;

Note: For details on SET statements, see the lesson Reading and Concatenating SAS Data Sets. For details on IF-THEN/ELSE statements, see the lesson Creating Variables.


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement