The LIBNAME statement
enables you to identify a library to SAS, specify which engine SAS
should use to process the library, and identify the
z/OS resources
that are required to process the library. For a complete discussion
of assigning libraries, see
Assigning SAS Libraries. For direct or sequential
access bound libraries, the LIBNAME statement can be used to specify
the necessary options to allocate the library data set. For information
about
z/OS allocation as it relates to SAS libraries, see
Allocating the Library Data Set.
Note: If an error is detected by
SAS while it is processing a LIBNAME statement, then the SAS session
return code will be unaffected unless the SAS system option ERRORCHECK=STRICT
is specified.
The form
of the LIBNAME statement that is used to assign a SAS library is described
in the following list. For examples of assigning libraries, see
Assigning an Existing Bound Library.
LIBNAME libref <engine> <'<file-system-prefix> physical-filename'> <engine/host-options> ;
LIBNAME libref <engine> <(library-specification-1,
..., library-specification-n)>
<engine/host-options'> ;
- libref
-
is a SAS name that
identifies the library. The libref can be a maximum of eight characters.
The first character must be a letter (A–Z) or an underscore.
The remaining characters can be any of these characters or numerals
0–9. This libref is used to reference the library throughout
SAS.
If the specified libref
is already assigned, SAS deassigns the libref before performing the
specified assignment.
If
a LIBNAME statement is specified without a physical filename and without
a list of library specifications, the libref is assumed to refer to
a
z/OS ddname that is allocated to a single
z/OS data set or UFS directory.
This allocation must be established external to SAS in the job step
or TSO session in which the SAS session is running. For more information,
see
Allocating the Library Data Set and Assigning SAS Libraries Externally.
Note: SAS 9.2 for
z/OS supports
libref names that begin with or contain underscores. For example,
libref names with formats such as libref_name, _librefname, or _libref_name
are now supported. Unlike filerefs, librefs cannot include the special
characters $, @, and #.
- engine
-
specifies which engine
to use to access the SAS library.
A
native library engine is an engine that accesses forms of SAS files
that are created and processed only by SAS. For a list of some of
the native library engines that can be specified in the LIBNAME statement,
see
SAS Library Engines. For
general information about these engines and other engines, see
SAS Engines in SAS Language Reference: Concepts.
It
is generally necessary to specify the engine only when creating a
library that is processed by an engine other than the default engine
that is indicated by the
ENGINE= System Option: z/OS or the SEQENGINE= System Option: z/OS.
For existing libraries, SAS can examine the format of the library
to determine which engine to use. For complete details about how SAS
selects an engine when an engine is not specified, see
How SAS Assigns an Engine.
Note:
-
The V5 and V5TAPE engine names
can be specified in the LIBNAME statement. These engines are still
supported for read-only access to existing libraries in those formats.
-
When
you assign a data-in-virtual (DIV) library that was created with
the V6 engine, the V6 engine must be explicitly specified. Otherwise,
the BASE engine for the current SAS release is used instead. For more
information about DIV libraries, see
Creating Hiperspace Libraries.
- physical-filename
-
specifies the physical
name of the library. The physical-filename syntax element and its
enclosing quotation marks can be omitted entirely. However, if a
quoted string is specified after the libref and engine, the physical-filename
that is enclosed in quotation marks must not have a length of zero.
A z/OS data set name or a UFS path can be specified for physical-filename.
If a file system prefix was not specified to indicate whether the
physical name refers to a z/OS data set or a UFS path, SAS assumes
that the physical name refers to a UFS path if any of the following
conditions are true:
-
The LIBNAME host option HFS is
specified.
-
The SAS system option FILESYSTEM=HFS
is in effect.
-
The physical name specified contains
a slash (/) or a tilde (~).
Otherwise, SAS assumes
that the physical name refers to a
z/OS data set.
The
physical-filename and
its
file-system-prefix, can
be specified in single quotation marks, as indicated in the syntax
diagram, or they can be specified in double quotation marks instead.
For a library that
resides in a
z/OS data set, the physical name of the library data
set can be specified in one of the following ways:
-
a fully qualified data set name.
For example:
'user934.mylib.saslib'
-
a partially qualified data name.
For example, if the value of the SYSPREF option is USER934, the
following specification is equivalent to the preceding example:
'.mylib.saslib'
For
more information, see
SYSPREF= System Option: z/OS.
-
a temporary data set name specified
as an ampersand (&), followed by one alphabetic character, and
up to seven additional alphanumeric or special ($, #, or @) characters.
For example:
'&tmp#lib1'
This specification
always creates a new temporary library, even if you have already specified
the same temporary data set name in a previous LIBNAME statement.
To assign an additional libref to a temporary library, specify the
original libref, as shown in the following example:
libname t '&tmp#lib1';
libname x (t);
Note: Temporary libraries receive
system-generated data set names in the following form, which is guaranteed
to be unique across the sysplex:
SYSyyddd.Thhmmss.RA000.jjobname.Rggnnnn
For a library that
resides in a UFS directory, the physical name of the library is the
directory path. This path can be specified in the following ways:
-
an absolute pathname:
'/u/userid/mylib'
a
pathname relative to the current working directory:
'./mylib'
or
'HFS:mylib'
The
HFS prefix is needed when the SAS system option FILESYSTEM=MVS is
in effect and the specified directory pathname does not contain a
slash ( / ) to indicate a UFS file. For more information, see
FILESYSTEM= System Option: z/OS.
-
a pathname relative to the home
directory of the user ID under which SAS is running:
'~/saslib';
If
the home directory of the user ID under which SAS is running is
/u/usera
,
then this specification is equivalent to
'/u/usera/saslib'
.
a pathname relative
to the home directory of another user ID:
'~userb/saslib';
If
the home directory for
userb
is
'/u/userhome/userb'
,
then the home directory is equivalent to
'/u/userhome/userb/saslib'
.
- library-specification
-
Specifies one of the
following:
'<file-system-prefix> physical-filename'
“<file-system-prefix> physical-filename”
libref
ddname
file-system-prefix and
physical-filename are
described in the preceding list.
libref is
described above and refers to any SAS libref currently assigned within
the SAS session.
ddname
ddname refers to a
z/OS ddname that is allocated to a single
z/OS
data set or UFS directory. This allocation must be established external
to SAS in the job step or TSO session in which the SAS session is
running. For more information about using a ddname, see
Allocating the Library Data Set and Assigning SAS Libraries Externally.
As
noted in the syntax diagram, multiple library specifications can be
specified in a single LIBNAME statement. In that case, the libref
refers to a logical concatenation of the libraries. For more information,
see
Library Concatenation in SAS Language Reference: Concepts. In addition, note that libraries
of different implementation types (such as direct access bound and
UFS) can be included within the concatenation.
- engine/host-options
-
are options that govern
processing of the SAS library. Each option is identified by a keyword,
and most keywords assign a specific value to that option. You can
specify one or more of these options using the following forms:
When you specify more than one option, use a blank
space to separate each option.
There
are two categories of options, engine options and host options. Engine
options can vary from engine to engine but are the same for all operating
environments. These options are documented as part of the syntax
of the
LIBNAME Statement in SAS Statements: Reference.
The host options, which are documented in the following sections,
apply exclusively to the
z/OS environment. For convenience, the host
options are divided into two groups, general options and options that
govern the allocation of a library data set. Many host options apply
only to certain library implementation types. For more information,
see
Library Implementation Types for Base and Sequential Engines.