Chapter Contents

Previous

Next
SAS Companion for the OpenVMS Operating Environment

Assigning OpenVMS Logical Names

There are some advantages to using the LIBNAME statement to identify your SAS data libraries to the SAS System. (See Advantages of Using Librefs Rather than OpenVMS Logical Names.) However, you can also use an OpenVMS logical name for the same purpose. To assign an OpenVMS logical name, use the DCL DEFINE command.

Note:   Because you cannot specify an engine name in the DCL DEFINE command, the SAS System uses the procedure described in How SAS Assigns an Engine When No Engine Is Specified to determine which engine to use.  [cautionend]

To use an OpenVMS logical name to refer to a SAS data library, you must define the logical name either outside the SAS System or from your SAS session using the SAS X statement. For example, you can assign the OpenVMS logical name MYLIB to the directory [MYDIR] in either of the following ways:


Using an OpenVMS Logical Name as a Libref

After assigning an OpenVMS logical name to a directory, you can use the logical name in a SAS job in the same way you would use a libref. For example, if you assigned the OpenVMS logical name MYLIB to a SAS data library, you could then use MYLIB as a libref in a SAS data step:

data mylib.a;
   set mylib.b;
run;

Similarly, you could use the logical name as a libref in a SAS procedure:

proc contents data=mylib._all_;
run;

Because the OpenVMS logical name is being used as a SAS name, it must follow the SAS naming conventions. For details about SAS naming conventions, see SAS Language Reference: Concepts.

The first time an OpenVMS logical name is used in this manner, SAS assigns it as a libref for the SAS data library. The logical name is not listed by the LIBNAME LIST statement until after you have used it in a SAS statement. (See Listing Your Current Librefs.)

Note:   OpenVMS logical names that are defined in a subprocess are not recognized by the current SAS session. However, OpenVMS logical names that are defined in the OpenVMS parent process are available for use during the current session. For information about how to use the X statement or the X command to define an OpenVMS logical name in the OpenVMS parent process, see Issuing DCL Commands during a SAS Session.  [cautionend]


Using an OpenVMS Logical Name in the LIBNAME Statement

Because you cannot specify an engine in the DCL DEFINE command, you may want to use the LIBNAME statement to specify an engine for a SAS data library to which you previously assigned an OpenVMS logical name. You can use the logical name in place of the libref in a LIBNAME statement, as in this example, which associates the BASE engine with the logical name MAIL:

libname mail base;

Alternatively, if you specify the logical name in place of the SAS-data-library argument of the LIBNAME statement, then you can associate both a libref and an engine with the logical name. The following example associates the libref IN and the BASE engine with the data library that is referred to by the logical name MAIL:

libname in base 'mail';

You can also use the LIBNAME statement to specify portable library options or engine/host options for a SAS data library to which you previously assigned an OpenVMS logical name. The following LIBNAME statement associates the libref MAIL and the V6TAPE engine with a path that includes the logical name MYDISK. It also specifies the portable library option ACCESS=:

libname mail v6tape 'mydisk:[mylib]' 
   access=readonly;


Using a Search-String Logical Name to Concatenate SAS Data Libraries

If you have several directories that you want to use as a single SAS data library, you can define an OpenVMS search-string logical name to the list of libraries, and then use that logical name in your SAS programs. The list of libraries can include both directories and other logicals. For example, the following X statement assigns the search-string logical name MYSEARCH to the directories [DIR1], [DIR2], [DIR3], and MYLIB2:

x 'define mysearch [dir1],[dir2],[dir3],mylib2';

When you reference the data set MYSEARCH.TEST1, the SAS System searches [DIR1], [DIR2], [DIR3], and then the directory pointed to by MYLIB2 for the TEST1 data set:

data new;
   set mysearch.test1;
   if total>10;
run;

You could also use a LIBNAME statement to assign the libref INLIBS to this series of directories. You use the search-string logical name as the SAS-data-library specification:

libname inlibs 'mysearch';

Files that are opened for input or update are opened from the first directory in which they are found. Files that are created or opened for output are always created in the first directory in the search list. For example, if a filename that you specify exists in both [DIR1] and [DIR3], SAS opens the file that is in [DIR1].

From the SAS Explorer's New Library dialog box, you can also specify a search-string logical name to assign a libref. To do this, type the search-string logical name in the Path: field.

For additional examples of how SAS files in concatenated SAS data libraries are accessed, see Accessing Files in Concatenated SAS Data Libraries.

For more information about search-string logical names, refer to OpenVMS User's Manual.


Concealed Logical Names

By default, SAS translates concealed logical names to their full physical specifications when they are used in LIBNAME statements. For example, consider the following definition for the logical name MYDISK:

$ DEFINE/TRANSLATION=CONCEALED -
_$ MYDISK $1$DUA100:[MYDISK.]

SAS translates the MYDISK concealed logical name to its full physical specification, resulting in the following libref definition:

1? LIBNAME MYLIB 'MYDISK:[MYDIRECTORY]';
Note: Libref MYLIB was successfully assigned
as follows:
Engine:  V8
Physical Name: $1$DUA100:[MYDISK.MYDIRECTORY]

Note:   The EXPANDLNM system option controls whether concealed logical names are expanded and displayed. Use the NOEXPANDLNM form of this option if you do not want your concealed logical names to be expanded and displayed. For more information, see EXPANDLNM.  [cautionend]


Chapter Contents

Previous

Next

Top of Page

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