Predefining SAS Libraries to the Server

Advantages of Predefining Libraries

Although it is not required, predefining one or more selected SAS libraries to the server for use by client applications provides the following advantages:
  • Applications can use the libref that you define to identify the library. This protects the applications against changes to the library's physical pathname.
  • The library is available to all clients that use the server's SQL services, including SAS clients that use the Remote SQL Pass-Through (RSPT) facility, and other clients that use the SAS ODBC driver, the JDBC driver, or the SQL library for C.
  • The server administrator can refer to the library with a libref in PROC OPERATE commands.
Be aware that the user ID from which the server runs must have the appropriate permissions to access the SAS library that you want to predefine to a server. You should be familiar with the permissions requirements of the operating environment, the network, and the security software before you predefine a library. For information about server security, see Server Security.

Methods for Predefining a Server Library

Predefining a Server Library by Using the LIBNAME Statement

In your server program, prior to specifying the PROC SERVER step, you can predefine one or more SAS libraries to the server by using the following syntax:
LIBNAME libref 'SAS-data-library' <options>;
How you specify the physical pathname of the SAS library and options depends on your operating environment. For details about the LIBNAME statement and options specific to your operating environment, see SAS Language Reference: Concepts and the SAS documentation for your operating environment.
Here is an example of how to predefine a library to the server for a UNIX operating environment by using the LIBNAME statement:
libname mylib '/payroll/div2/emp';
After you define a library to the server, a message is displayed in the SAS log. For example, here is a message for a server on a UNIX operating environment:
1     libname mylib '.'; 
NOTE: Libref MYLIB was successfully assigned as follows:
Engine: V9
Physical Name: /payroll/div2/emp
CAUTION:
You are discouraged from using the FILELOCKWAIT= option in the LIBNAME statement,
which specifies the maximum length of time that a SAS/SHARE client or server will wait for a SAS file that has been locked by another process to become available for use. If the wait time expires before the file becomes available, the SAS/SHARE request to open the file will fail and a message is written to the log. When using SAS/SHARE to access SAS files, do not perform additional jobs that might contend for access to the same files. For details about the FILELOCKWAIT= option in the LIBNAME statement, see the SAS Companion for UNIX Environments or the SAS Companion for Windows, as appropriate.

Predefining a Server Library by Using the ALLOCATE LIBRARY Command in PROC OPERATE

In a server administrator session, while the server is running, you can predefine one or more SAS libraries to the server by using the following syntax:
PROC OPERATE SERVER=server-ID;
ALLOCATE LIBRARY libref 'SAS-data-library' <options>;
How you specify the physical pathname of the SAS library and options depends on your operating environment. For details about the ALLOCATE LIBRARY command, see Defining a Library to a Server That Is Running. For details about options specific to an operating environment, see SAS System Options: Reference and the SAS documentation for your operating environment.
Here is an example of using the ALLOCATE LIBRARY command in a PROC OPERATE step under Windows:
proc operate server=share1;
  allocate library mylib '\payroll\dev2\emp';  
Note: In addition to these recommended methods, you can also define a libref externally to SAS. For this information, see the SAS documentation for your operating environment.