Pre-assigning a Library

Overview of Pre-assigning a Library

Pre-assigning a large number of libraries can have a negative impact on the execution time of SAS programs for all users. Therefore, be judicious in deciding whether to pre-assign a library.
Pre-assigning a library is a two-stage process:
  1. Flag the library as pre-assigned.
  2. Edit the configuration files.
Note: Keep in mind that pre-assigning the library does not mean that you do not need to register tables in metadata. You must register the tables so that applications that read tables from metadata, such as SAS Data Integration Studio, can work with the tables.

Stage 1: Flag the Library as Pre-assigned

A library can be configured to be assigned by the server process by either selecting the Library is pre-assigned advanced option when the library is being registered or by modifying the library's properties after the fact. To pre-assign a library, perform the following steps:
  1. From SAS Management Console, select Data Library Managerthen selectLibrariesthen selectlibrary-namethen selectProperties.
  2. Select the Options tab.
  3. Click the Advanced Options button.
  4. Select the check box on the Pre-Assign tab, and select an option from the Pre-Assignment Type menu.
    Library Is Pre-assigned Option
    Library Is Pre-assigned Option
    Tip
    Select By external configuration when you want to pre-assign the library in a configuration file, such as an autoexec.
  5. Click OK on the Advanced Options dialog box.
  6. Click the Assign tab on the library properties window.
  7. Select the servers that you want to pre-assign the libraries to. Click OK when you are finished.
    Figure showing the Assign tab for a library properties dialog box

Stage 2: Edit the Configuration Files

In the previous stage, the library was flagged as pre-assigned. You also selected which servers can retrieve the library definitions from metadata. In this stage, you edit the sasv9_usermods.cfg file for the same servers that were selected in the previous stage and add a METAAUTORESOURCES SAS system option. This option is used so that the servers read the library definitions from metadata as they start.
Note: This stage is not needed for workspace servers, pooled workspace servers, stored process servers, SAS/SHARE servers, or OLAP servers. Those server types automatically read metadata when they start and assign the libraries.
To edit the configuration files, perform the following steps:
  1. For each SAS/CONNECT server, edit the following file:
    SAS-config-dir\Lev1\SASApp\ConnectServer\sasv9_usermods.cfg
    Add the following SAS system option:
    -metaautoresources 'SASApp'
  2. For each DATA Step Batch server, edit the following file:
    SAS-config-dir\Lev1\SASApp\DataStep\sasv9_usermods.cfg
    Add the following SAS system option:
    -metaautoresources 'SASApp'

Pre-assigning Libraries to Use the Metadata Engine

If You Do Not Need to Create or Delete Tables

Pre-assigning a library to use the metadata engine is available by selecting the By metadata library engine option for a library on the Advanced Options dialog box. Using this option results in using the metadata engine with the METAOUT=ALL option. This LIBNAME option specifies that you can read, create, update, and delete observations in physical tables that already exist and are registered in metadata. You cannot create or delete entire physical tables.

If You Need to Create or Delete Tables

Other METAOUT= LIBNAME options exist. For example, the METAOUT=DATA option permits reading, creating, updating, and deleting physical tables. The METAOUT=DATAREG setting permits reading, updating, and deleting tables registered in metadata as well as creating new physical tables. Be aware that new physical tables cannot be read until they are registered in metadata. For more information, see the “METAOUT= Argument” in SAS Language Interfaces to Metadata.
If the METAOUT=ALL setting does not meet your business needs, but the data-level authorizations do meet your business needs, you can pre-assign the library to use the metadata engine in a configuration file. To do so, perform the following high-level steps:
  1. Follow all the steps in Stage 1: Flag the Library as Pre-assigned. When you set the pre-assignment type in step 4, select By external configuration.
    Note: Do not choose By metadata library engine. In order to use a different METAOUT= option, you must specify the LIBNAME statement in an external configuration file.
  2. Construct a LIBNAME statement that uses the metadata engine and your preferred METAOUT= option. For an example, see Metadata LIBNAME Engine Statement.
  3. Determine which autoexec file to use for the LIBNAME statement. For more information, see SAS Application Server Autoexec Files.
The metadata engine can reference a library by the library name. For a library that is registered in metadata with a name of Accounting tables and a libref of lib1, the following LIBNAME statement accesses the tables with the metadata engine:
Metadata LIBNAME Engine Statement
libname lib1 meta library="Accounting tables" metaout=datareg;

Pre-assigning Libraries in an Autoexec File

Pre-assigning libraries in an autoexec file is not a recommended as a routine practice because library assignments are recorded in two places, the autoexec file and metadata. Having configuration information in two places increases maintenance. An autoexec file is a text file that contains SAS statements that are executed when the server process starts. If an autoexec file is used in your environment, it is important to note that the LIBNAME statements in the autoexec file take precedence over same-named libraries assigned by to the server in metadata. For example, if ORGOLD is registered in the metadata to be pre-assigned, and ORGOLD is also defined in an autoexec for the same server, the ORGOLD library is assigned using the LIBNAME information from the autoexec file. Simply put, the library assignment in the autoexec file always takes precedence.
To pre-assign a library in an autoexec file, perform the following high-level steps:
  1. Follow all the steps in Stage 1: Flag the Library as Pre-assigned. When you set the pre-assignment type in step 4, select By external configuration.
  2. Construct a LIBNAME statement.
  3. Determine which autoexec file to use for the LIBNAME statement. For more information, see SAS Application Server Autoexec Files.
The following display shows LIBNAME statements that pre-assign libraries in an autoexec file. The comments in the display acknowledge how pre-assigning a library in an autoexec file and registering the same library in metadata can cause unexpected results when accessing data.
Library Assignment in an Autoexec File
Library Assignment in an Autoexec File

SAS Application Server Autoexec Files

During the configuration process, the SAS Deployment Wizard created a single file named appserver_autoexec_usermods.sas that controls all component servers of the SAS Application Server and files named autoexec_usermods.sas for each of the component servers of the application server:
  • appserver_autoexec_usermods.sas
    Use this file if you want all the SAS Application Server components registered to the application server, such as an OLAP server, a workspace server, and so on, to access the library with the same SAS engine.
  • autoexec_usermods.sas
    Use this file to modify one of the SAS Application Server components, such as the workspace server, to use the engine specified in the LIBNAME statement, but to leave the other server components unchanged. If this is your choice, then note that the autoexec_usermods.sas file is located within a subdirectory, such as C:\SAS\Config\Lev1\SASApp\WorkspaceServer\.