A SERVICE OF

logo

63
CHAPTER
9
The LIBNAME Statement for
Relational Databases
Overview of the LIBNAME Statement for Relational Databases
63
Sorting Data
63
Using SAS Functions
63
Assigning a Libref Interactively
64
LIBNAME Options for Relational Databases
68
Overview of the LIBNAME Statement for Relational Databases
The SAS/ACCESS LIBNAME statement extends the SAS global LIBNAME statement
to enable you to assign a libref to a relational DBMS. This feature lets you reference a
DBMS object directly in a DATA step or SAS procedure, enabling you to read from and
write to a DBMS object as though it were a SAS data set. You can associate a SAS
libref with a relational DBMS database, schema, server, or group of tables and views.
Sorting Data
When you use the SAS/ACCESS LIBNAME statement to associate a libref with
relational DBMS data, you might observe some behavior that differs from that of normal
SAS librefs. Because these librefs refer to database objects, such as tables and views,
they are stored in the format of your DBMS, which differs from the format of normal
SAS data sets. This is helpful to remember when you access and work with DBMS data.
For example, you can sort the observations in a normal SAS data set and store the
output to another data set. However, in a relational DBMS, sorting data often has no
effect on how it is stored. Because you cannot depend on your data to be sorted in the
DBMS, you must sort the data at the time of query. Furthermore, when you sort DBMS
data, the results might vary depending on whether your DBMS places data with NULL
values (which are translated in SAS to missing values) at the beginning or the end of
the result set.
Using SAS Functions
When you use librefs that refer to DBMS data with SAS functions, some functions
might return a value that differs from what is returned when you use the functions
with normal SAS data sets. For example, the PATHNAME function might return a
blank value. For a normal SAS libref, a blank value means that the libref is not valid.
However, for a libref associated with a DBMS object, a blank value means only that
there is no pathname associated with the libref.
Usage of some functions might also vary. For example, the LIBNAME function can
accept an optional SAS-data-library argument. When you use the LIBNAME function to