A SERVICE OF

logo

66 LIBNAME Statement Syntax for Relational Databases Chapter 9
Specify libref to disassociate a single libref. Specify _ALL_ to disassociate all
currently assigned librefs.
_ALL_
specifies that the CLEAR or LIST argument applies to all currently-assigned librefs.
LIST
writes the attributes of one or more SAS/ACCESS libraries or SAS data libraries to
the SAS log.
Specify libref to list the attributes of a single SAS/ACCESS library or SAS data
library. Specify _ALL_ to list the attributes of all libraries that have librefs in your
current session.
Details
u Using Data from a DBMS
You can use a LIBNAME statement to read from and
write to a DBMS table or view as though it were a SAS data set.
For example, in MYDBLIB.EMPLOYEES_Q2, MYDBLIB is a SAS libref that points
to a particular group of DBMS objects, and EMPLOYEES_Q2 is a DBMS table name.
When you specify MYDBLIB.EMPLOYEES_Q2 in a DATA step or procedure, you
dynamically access the DBMS table. SAS supports reading, updating, creating, and
deleting DBMS tables dynamically.
v Disassociating a Libref from a SAS Data Library
To disassociate or clear a libref
from a DBMS, use a LIBNAME statement, specifying the libref (for example,
MYDBLIB) and the CLEAR option as follows:
libname mydblib CLEAR;
You can clear a single specified libref or all current librefs.
The database engine disconnects from the database and closes any free threads or
resources that are associated with that libref’s connection.
w Writing SAS Data Library Attributes to the SAS Log
Use a LIBNAME statement to
write the attributes of one or more SAS/ACCESS libraries or SAS data libraries to the
SAS log. Specify libref to list the attributes of a single SAS/ACCESS library or SAS
data library, as follows:
libname mydblib LIST;
Specify _ALL_ to list the attributes of all libraries that have librefs in your current
session.
SQL Views with Embedded LIBNAME Statements
With SAS software, you can embed LIBNAME statements in the definition of an SQL
view. This means that you can store, in an SQL view, a LIBNAME statement that
contains all the information required to connect to a DBMS. Whenever the SQL view is
read, PROC SQL uses the embedded LIBNAME statement to assign a libref. After the
view has been processed, PROC SQL de-assigns the libref.
In this example, an SQL view of the Oracle table DEPT is created. Whenever this
view is used in a SAS program, the library ORALIB is assigned, using the connection
information (user name, password, and data source) that is provided in the embedded
LIBNAME statement.
proc sql;
create view sasuser.myview as
select dname from oralib.dept