Using SAS Files |
Listing Your Current Librefs under OpenVMS |
As in other operating environments, you can view your current librefs using the following methods:
the LIBNAME statement. The syntax for this statement is the following:
LIBNAME _ALL_ LIST; |
the LIBNAME window. To open the LIBNAME window, enter libname on the command line.
the SAS Explorer window. To see information about your currently assigned SAS libraries, complete the following steps:
the Properties dialog box. Select the libref. With the cursor on the highlighted libref, click and hold the right mouse button. A pop-up menu opens. Select Properties .
OpenVMS logical names that you have assigned to SAS libraries are also listed, but only after you have used them as librefs in your current SAS process. (See Using an OpenVMS Logical Name as a Libref.)
Methods for 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 under OpenVMS.
The LIBNAME statement identifies a SAS library to SAS, associates an engine with the library, enables you to specify options for the library, and assigns a libref to it. For details about LIBNAME statement syntax, see LIBNAME Statement: OpenVMS.
The LIBNAME function takes the same arguments and options as the LIBNAME statement. For more information about the LIBNAME function, see LIBNAME Function: OpenVMS.
Perform the following steps to assign a libref using the DMLIBASSIGN command:
Issue the DMLIBASSIGN command in the command window. The New Library dialog box opens.
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 might change.
Click the Enable at startup box to assign this libref when SAS starts.
Specify the necessary information for the SAS library in the Library Information area. Depending on the engine selected, there might or might not be a Path field available for input.
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.
Perform the following steps to assign a libref from the LIBNAME window:
Issue the LIBNAME command in the command window. The LIBNAME window opens.
From the File pull-down menu, select New . The New Library dialog box opens.
Fill in the fields in the New Library dialog box, described in Using the DMLIBASSIGN Command.
Perform the following steps to assign a libref from the SAS Explorer window:
From the File pull-down menu, select New when the Libraries node in the tree structure is active. The New dialog box opens.
Select Library , and then click OK. The New Library dialog box opens.
Fill in the fields in the New Library dialog box, described in Using the DMLIBASSIGN Command.
When you create a libref using the New Library window and selecting Enable at Startup, SAS saves the libref definition in the SAS registry. Then, in subsequent SAS sessions, when you start SAS using the STARTLIB system option, SAS assigns the libref from the libref definition in the SAS registry.
In the windowing environment, STARTLIB is the default setting for the option. Therefore, it is not necessary to specify the option when you start the SAS in the windowing environment.
To automatically assign librefs in all other operating modes (batch, interactive line mode, and noninteractive mode), you must create the libref in the windowing environment. Then, when you start SAS in another operating mode, specify the STARTLIB system option either on the command line or in the configuration file.
To create the libref in the windowing environment, issue the DMLIBASSIGN command to open the New Library window. Enter the libref name, engine, location, and options, and then select Enable at Startup.
For more information about the STARTLIB option, see STARTLIB System Option in the SAS Language Reference: Dictionary.
An alternative method for automatically assigning librefs is to add LIBNAME statements to an AUTOEXEC file. The AUTOEXEC file contains SAS statements that execute immediately after SAS is initialized. For more information about AUTOEXEC files in OpenVMS, see Autoexec Files.
Multiple SAS Libraries in a Single Directory |
A SAS 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 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 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.)
Suppose that the directory [MYDIR] contains SAS files that were created by the V9 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 v9 '[mydir]'; libname two concur '[mydir]';
Data sets that are subsequently referenced by the libref ONE are created and accessed using the V9 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 Library |
You can assign multiple librefs to the same SAS library (or engine-directory combination), and you can use those librefs interchangeably.
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 library and proceed.
The following LIBNAME statements assign the librefs MYLIB and INLIB to the same SAS library:
libname mylib v9 '[mydir.datasets]'; libname inlib v9 '[mydir.datasets]';
Because the engine names and SAS library specifications are the same, the librefs MYLIB and INLIB are identical and interchangeable.
Clearing Librefs under OpenVMS |
To disassociate a libref from a SAS library, use the following forms of the LIBNAME statement or the LIBNAME function, where libref is the libref of the library that you want to clear:
In both cases, the libref is cleared only if there are no open files that are associated with that libref, and the libref is cleared only for the SAS process or job from which you submit the LIBNAME statement or function.
You can also use the SAS Explorer window to clear librefs, as follows:
With the tree structure activated, select the libref from the Libraries node.
With the cursor on the highlighted libref, click and hold the right mouse button.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.