Dynamic LIBNAME Engine
SAS/ACCESS LIBNAME Statement
Beginning in SAS 7, you can associate a SAS libref directly with a database, schema,
server, or group of tables and SAS views, depending on your DBMS. To assign a libref
to DBMS data, you must use the SAS/ACCESS LIBNAME statement, which has syntax
and options that are different from the Base SAS LIBNAME statement. For example, to
connect to an ORACLE database, you might use the following SAS/ACCESS
LIBNAME statement:
libname mydblib oracle user=smith password=secret path='myoracleserver';
This LIBNAME statement connects to ORACLE by specifying the ORACLE
connection options: USER=, PASSWORD=, and PATH=. In addition to the connection
options, you can specify SAS/ACCESS LIBNAME options that control the type of
database connection that is made. You can use additional options to control how your
data is processed.
You can use a DATA step, SAS procedures, or the Explorer window to view and update
the DBMS data associated with the libref, or use the DATASETS and CONTENTS
procedures to view information about the DBMS objects.
See your SAS/ACCESS documentation for a full listing of the SAS/ACCESS
LIBNAME options that can be used with librefs that refer to DBMS data.
Using Data Set Options with SAS/ACCESS Librefs
After you have assigned a libref to your DBMS data, you can use SAS/ACCESS data set
options, and some of the Base SAS data set options, on the data. The following example
associates a libref with DB2 data and uses the SQL procedure to query the data:
libname mydb2lib db2;
proc sql;
select *
from mydb2lib.employees(drop=salary)
where dept='Accounting';
quit;
The LIBNAME statement connects to DB2. You can reference a DBMS object, in this
case, a DB2 table, by specifying a two-level name that consists of the libref and the
DBMS object name. The DROP= data set option causes the SALARY column of the
EMPLOYEES table on DB2 to be excluded from the data that is returned by the query.
See your SAS/ACCESS documentation for a full listing of the SAS/ACCESS data set
options and the Base SAS data set options that can be used on data sets that refer to
DBMS data.
Embedding a SAS/ACCESS LIBNAME Statement in a PROC SQL
View
You can issue a SAS/ACCESS LIBNAME statement by itself, as shown in the previous
examples, or as part of a CREATE VIEW statement in PROC SQL. The USING clause
704 Chapter 31 About SAS/ACCESS Software
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.61.81