Assigns or deassigns a libref for a SAS data library
Category: SAS File I/O
See: LIBNAME Function in the documentation for your operating environment.
LIBNAME ( libref <, SAS-data-library <, engine <, options >>>)
libref
specifies the libref that is assigned to a SAS data library.
SAS-data-library
specifies the physical name of the SAS data library that is associated with the libref. Specify this name as required by the host operating environment.
engine
specifies the engine that is used to access SAS files opened in the data library. If you are specifying a SAS/SHARE server, then the engine should be REMOTE.
options
names one or more options honored by the specified engine, delimited with blanks.
If the LIBNAME function returns 0, then the function was successful. However, you could receive a non-zero value, even if the function was successful. A non-zero value is returned if an error, warning, or note is produced. To determine if the function was successful, look through the SAS log and use the following guidelines:
If a warning or note was generated, then the function was successful.
If an error was generated, then the function was not successful.
Operating Environment Information: Some systems allow a SAS-data-library value of ' ' (with a space) to assign a libref to the current directory. The behavior of LIBNAME when a single space is specified for SAS-data-library is host dependent.
If no value is provided for SAS-data-library or if SAS-data-library has a value of " (with no space), LIBNAME disassociates the libref from the data library.
Under some operating environments, the user can assign librefs using system commands outside the SAS session.
This example attempts to assign the libref NEW to the SAS data library MYLIB. If an error or warning occurs, the message is written to the SAS log. Note that in a macro statement you do not enclose character strings in quotation marks.
%if (%sysfunc(libname(new,MYLIB))) %then %put %sysfunc(sysmsg());
This example deassigns the libref NEW that has been previously associated with the data library MYLIB in the preceding example. If an error or warning occurs, the message is written to the SAS log. Note that in a macro statement you do not enclose character strings in quotation marks.
%if (libname(new)) %then %put %sysfunc(sysmsg());
Function:
'LIBREF Function' on page 634