This statement creates a libref, MYDBLIB, that uses
the
SAS/ACCESS interface to DB2.
libname mydblib db2 ssid=db2a authid=testid server=os390svr;
The statement below
associates the SAS libref MYDBLIB with an Oracle database that uses
the SQL*Net alias AIRDB_REMOTE. You specify the SCHEMA= option in
the
SAS/ACCESS LIBNAME statement to connect to the Oracle schema in
which the database resides. In this example, Oracle schemas reside
in a database.
libname mydblib oracle user=testuser password=testpass
path=airdb_remote schema=hrdept;
The AIRDB_REMOTE database
contains a number of DBMS objects, including several tables, such
as STAFF. After you assign the libref, you can reference the Oracle
table like a SAS data set and use it as a data source in any DATA
step or SAS procedure. In the SQL procedure statement below, MYDBLIB.STAFF
is the two-level SAS name for the STAFF table in the Oracle database
AIRDB_REMOTE.
proc sql;
select idnum, lname
from mydblib.staff
where state='NY'
order by lname;
quit;
You can use the DBMS
data to create a SAS data set.
data newds;
set mydblib.staff(keep=idnum lname fname);
run;
You can also use the
libref and data set with any other SAS procedure. This statement prints
the information in the STAFF table.
proc print data=mydblib.staff;
run;
This statement lists
the database objects in the MYDBLIB library.
proc datasets library=mydblib;
quit;