Chapter Contents


SAS Companion for the OpenVMS Operating Environment

Assigning Librefs

You can use any of the following methods to assign a SAS libref:

A libref assignment remains in effect for the duration of the SAS job, session, or process unless you either clear the libref or use the same libref in another LIBNAME statement or LIBNAME function.

If you assign a libref from a SAS process, that libref is valid only within that SAS process.

If you clear a libref from within a SAS process, that libref is not cleared from other SAS processes. For information about clearing librefs, see Clearing Librefs.

Using the LIBNAME Statement

The LIBNAME statement identifies a SAS data library to the SAS System, associates an engine with the library, allows you to specify options for the library, and assigns a libref to it. For details about LIBNAME statement syntax, see LIBNAME.

Using the LIBNAME Function

The LIBNAME function takes the same arguments and options as the LIBNAME statement. For more information about the LIBNAME function, see LIBNAME.

Using the LIBASSIGN Command

Perform the following steps to assign a libref using the LIBASSIGN command:

  1. Issue the LIBASSIGN command in the command window. The New Library dialog box opens.

  2. Specify the libref in the Name: field.

  3. Specify an engine for the libref in the Engine: field by selecting the default engine or another engine from the drop-down menu. Depending on the engine that you specify, the fields in the Library Information: area may change.

  4. Click on the Enable at startup box to assign this libref when you invoke SAS.

  5. Specify the necessary information for the desired SAS data library in the Library Information: area. Depending on the engine selected, there may or may not be a Path:field available for input.

  6. Specify LIBNAME options in the Options: field. These options can be specific to your host or engine, including options that are specific to a SAS engine that accesses another software vendor's relational database system.

  7. Select [OK].

Using the SAS Explorer Window

Perform the following steps to assign a libref from the SAS Explorer window:

  1. From the File pull-down menu, select New when the Libraries node in the tree structure is active. The New dialog box opens.

  2. Select Library, and then select [OK]. The New Library dialog box opens.

  3. Fill in the fields in the New Library dialog box, described in Using the LIBASSIGN Command.

  4. Select [OK].

Multiple SAS Data Libraries in a Single Directory

A SAS data library consists of all the SAS files in the same OpenVMS directory (or in a group of directories--see Using a Search-String Logical Name to Concatenate SAS Data Libraries) that are accessed by the same engine. If a directory contains SAS files that are accessed by different engines, then you have more than one SAS data library in the directory, and you should therefore have a different libref for each engine-directory combination. (You cannot assign the same libref to more than one engine-directory combination. The second assignment merely overrides the first assignment.)

For example, suppose that the directory [MYDIR] contains SAS files that were created by the V8 engine as well as SAS files that were created by the CONCUR engine. You could use the following LIBNAME statements to assign different librefs to the two engines:

libname one v8 '[mydir]';
libname two concur '[mydir]';

Data sets that are subsequently referenced by the libref ONE are created and accessed using the V8 engine. Data sets that are referenced by the libref TWO are created and accessed using the CONCUR engine. You can then concatenate librefs ONE and TWO and access all files:

libname concat (one two);

Multiple Librefs for a Single SAS Data Library

You can assign multiple librefs to the same SAS data library (or engine-directory combination), and you can use those librefs interchangeably. For example, suppose that in two different programs you used different librefs for the same data sets. Later you develop a new program from parts of the two old programs, or you use the %INCLUDE statement to include two different programs. In the new program, you could simply assign the two original librefs to each data library and proceed.

The following LIBNAME statements assign the librefs MYLIB and INLIB to the same SAS data library:

libname mylib v8 '[mydir.datasets]';
libname inlib v8 '[mydir.datasets]';

Because the engine names and SAS data library specifications are the same, the librefs MYLIB and INLIB are identical and interchangeable.

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.