LIBREF Function

Verifies that a libref has been assigned.

Category: SAS File I/O



Required Argument


specifies the libref to be verified. In a DATA step, libref can be a character expression, a string enclosed in quotation marks, or a DATA step variable whose value contains the libref. In a macro, libref can be any expression.

Range 1 to 8 characters


The LIBREF function returns 0 if the libref has been assigned, or returns a nonzero value if the libref has not been assigned.


This example verifies a libref. If an error or warning occurs, the message is written to the log. Under some operating environments, the user can assign librefs by using system commands outside the SAS session.
%if (%sysfunc(libref(sashelp))) %then
  %put %sysfunc(sysmsg());

See Also