Chapter Contents

Previous

Next
SAS Companion for the CMS Environment

Working with SAS Files on Tape

When you write more than one SAS data library on a tape, remember that each library is a single tape file as long as the same libref is used for each SAS library member. A SAS data library that contains more than one member on tape is just one tape file.

Under CMS, SAS uses CMS tape-handling facilities to process tape libraries. Before you use tape libraries, see Tape Processing. Also, read about tape processing under CMS in the CMS User's Guide and in the CMS Command Reference.


Tape Processing

The SAS System under CMS enables you to exploit the tape-handling facilities that are provided by CMS. Both SAS data libraries and external files are accessed through the Basic Sequential Access Method (BSAM). This standard interface supports labeled or unlabeled tapes as well as multifile and multivolume facilities. Any supported external tape management system can be used. Read about tape processing in VM/ESA CMS User's Guide and in VM/ESA CMS Command Reference.

For Version 8, four tape engines are supported: V5TAPE (READ-only), V6TAPE, V7TAPE, and V8TAPE. Specifying only TAPE defaults to the current release.

Using the LIBNAME and FILENAME Options for Tape Processing

SAS uses a LIBNAME statement or function to access SAS data libraries and a FILENAME statement to access external files. See Statements in the CMS Environment for details about these statements. The LIBNAME and FILENAME statements provide the following special options particular to tape processing:

DISP=MOD
specifies that the COPY procedure is to append new members to the end of a sequential library that is allocated with this option. By default, the COPY procedure replaces all existing members in the sequential library with the new members copied from the source library. The DISP=MOD option is valid only for libraries that use the V6TAPE or later engine, and is valid only with the COPY procedure. When this option is in effect, SAS does not check the destination sequential library for duplicate members. Any duplicate members that are not renamed will not be accessed by SAS, since SAS will always access the existing member with the same name first.

LABEL=BLP n
label processing is bypassed. An integer n (the default value is 1) causes positioning to a specific file on a multifile tape when it is opened.

LABEL=LABOFF
indicates that no tape label processing is desired. A tape is not repositioned before open processing or after close processing; a CMS TAPE command is used to reposition the tape if needed.

LABEL=NL n
unlabeled tapes are desired. An NL tape is always rewound at open to perform label checks. A standard labeled tape is not opened when NL is specified. After label checking, the tape is positioned to logical file n.

LABEL=SL n
indicates that IBM standard labels are needed. Standard labeled tapes enable SAS data libraries or external files to span multiple tape volumes. If a tape management system is installed, the mounting of SL tapes can be deferred until the files are opened.

LEAVE=YES
indicates that a multifile tape is not repositioned at open for LABOFF or BLP processing. For SL tapes, LEAVE=YES does not reposition before label processing. Omitting LEAVE or specifying LEAVE=NO causes a tape to be rewound and repositioned each time a file is opened.

SYSPARM=value
is used to pass tape mounting parameters to an external tape management system. When value contains blanks or parentheses, use the form SYSPARM=? to cause an ENTER SYSPARM prompt. At the prompt, 130 characters of SYSPARM values can be entered. See the documentation for your external tape management system for valid values.

VOLID=vvvvvv
defines a one- to six-character volume serial identifier for standard labeled tapes. When you use the VOLID= option, the VOL1 label on the tape is verified when a tape file is opened. When you omit VOLID=, no VOL1 check is made.


Using CMS Command Options for Tape Processing

When SL tapes are used, use a CMS LABELDEF command to supplement a SAS LIBNAME or FILENAME statement. The LABELDEF command enables you to define fields in the standard HDR1 or EOF1 tape labels. The defined fields or their default values are checked for input files or are written for output files. The LABELDEF command is required when multivolume tape files are used, when input checking is needed, or when specific values are to be written into standard labels. See the VM/ESA CMS Command Reference for more details. The filename field in a LABELDEF command should be the same name that is used as a libref in a LIBNAME statement or function or as the fileref in a FILENAME statement.

Mounting Tapes

The method that is used to have a tape mounted and a drive attached to your userid is specific to your computing installation. Some installations have special commands for tape mounts; others require that you send messages to your computer operator. Ask your SAS Installation Representative or other installation personnel about your local procedures.

If an external tape management system is available at your installation, it may be possible to defer mounting of tapes until the tape file is opened. In most cases, however, the tape drive must be attached to your userid with a tape mounted and ready before the tape file can be opened.

Positioning Tapes

When LABEL=SL, NL, or BLP, SAS automatically positions a tape to the proper file when the file is opened. No manual repositioning is needed in most cases.

When either LABEL=LABOFF or LEAVE=YES is used, tape positioning becomes a user responsibility. The CMS commands TAPE REW (rewind), TAPE FSF (forward space file), and TAPE BSF (backspace file) are needed to position a tape to the proper file before processing.

Miscellaneous Tape Notes


Tape Processing Example 1: Creating a SAS Data Library without Label Processing

/* Assume that the tape has been premounted */
/* at virtual address 182                   */

libname favorite tape 'tap2';
cms tape rew;
data favorite.fruits( filedisp=new );
   set mylib.oranges;
run;

The TAPE REW command ensures that the tape is rewound to file 1. FILEDISP=NEW is needed to create the first member in any tape library.

Tape Processing Example 2: Adding a New Member to an Existing SAS Data Library

/* Assume a premounted tape at address 183 */

libname fall89 tape 'tap3' label=NL 2;
data fall89.scores;
   input student $11. test 3.0;
cards;
...more data lines...

run;

For NL tapes, positioning is handled by the SAS System under CMS. No TAPE commands are used. FILEDISP=NEW is not specified because the SAS data library already exists in file 2.

Tape Processing Example 3: Creating a Multivolume External File

/* Assume the first tape volume VM0202 is */
/* mounted at address 181                 */

cms labeldef test1 fid ? volid ?;
DMSLBD220R Enter dataset name:
external.test.file
DMSLBD441R Enter VOLID information:
vm0202 vm0203
DMSLBD441R Enter VOLID information:
 ...null line entered...

filename test1 tape 'tap1' label=sl;
data; file test1;
   do i = 1 to 100000; 
      put i; 
   end;
run;
DMSTLM428I TAP1(181) EOV1 label written on VM0202
DMSTVS265I Attempting to change tape volume for DDNAME TEST1
DMSTVS266I To cancel the tape volume switch, type CANCEL
DMSTVS268I Message sent to userid OPERATOR:
DMSTVS269I Mount tape volume VM0203 on virtual 181 with a write ring;
request number 1

The CMS interface module uses the arguments for the LABELDEF command to switch to the second volume when the first volume is filled and its EOV1 label has been written.

Tape Processing Example 4: Retrieving a Multivolume Tape File Managed by an External Tape Management System

/* Assume the tape management system */
/* supports deferred tape mounts     */

cms labeldef test2 fid ?;
DMSLBD220R Enter dataset name:
wx.test.file
filename test2 tape 'tap1' label=sl sysparm=queue;
Beginning DMSTVI SYSPARM processing.

data;
   infile test2;
   input x y z;
run;

Beginning DMSTVI OPEN processing
TAPE nnnn ATTACHED TO userid 0181

...more system output...

DMSTLM427I TAP1(181) EOV1 label read
Beginning DMSTVI EOV processing.
TAPE 0181 DETACHED
TAPE nnnn ATTACHED TO userid 0181
 
...more system output...
  
Beginning DMSTVI CLOSE processing.

The external tape system handles the tape mounts when the tape file is opened and when the volume switch occurs. The LABELDEF command identifies the file by its data set name.

Tape Processing Example 5: Retrieving a SAS Data Library from One Tape File and an External File from a Second Tape File

/* Assume the tape has been mounted as 184*/

libname first tape 'tap4' label=blp;
cms tape rew;
data a;
   set first.member;
run;

filename second tape 'tap4' label=blp 2 leave=yes;

data;
   infile second;
   input a b;
run;

The CMS TAPE REW command positions the tape initially to the load point. Because LEAVE=YES is specified, the tape is not repositioned when the file SECOND is read. Without LEAVE=YES, the program still runs, but when SECOND is opened, the tape is rewound and is spaced forward unnecessarily.


Assigning a Libref to a Sequential Library

When a LIBNAME statement or function defines a libref for a library that is in sequential format, SAS automatically issues a FILEDEF command for the library. If you issue a FILEDEF command prior to the LIBNAME statement or function, then that FILEDEF is used.

Most of the options that you can specify in a CMS FILEDEF command can also be specified as LIBNAME statement or function options. Options that are needed for sequential processing are also available with the LIBNAME statement or function. (See LIBNAME for a complete list of LIBNAME statement or function options.) Therefore, it is feasible for you to replace all FILEDEF commands in an existing SAS application with corresponding LIBNAME statement or functions.

To process a sequential data library, use the following form of the LIBNAME statement or function:

LIBNAME libref TAPE TAPn;

The libref is any valid SAS libref. TAPE designates the TAPE (sequential) engine, and TAPn specifies the tape device. Here are some examples of LIBNAME statements and explanations of where the library is assumed to be located:


Specifying an Old or New Library with the FILEDISP= Option

When writing a SAS file to a sequential library, you must be aware of the effects of the SAS data set option FILEDISP= . The FILEDISP= data set option tells SAS whether the file being written is a member of an existing SAS data library on the tape or is the first member of a new library.

When FILEDISP=OLD (the default) is in effect, SAS assumes that you are writing a member to an existing sequential library. During such a write, SAS searches the sequential library, which consists of a single SAS file, for a member that has the same name. If a matching member is found, SAS writes the new member over the existing member. Any members that appeared after the updated member are lost. If SAS does not find a matching member, it assumes that it has come to the end of the library. SAS then writes the new member at the end of the library.

If you specify FILEDISP=NEW, SAS assumes that you are creating a new library, and writes the new member at the beginning of the SAS file that represents the sequential library. After the initial write, SAS assumes FILEDISP=OLD for that libref. Subsequent writes can be submitted with FILEDISP=NEW, but the NEW value will be ignored. This prevents unintentional data loss after the initial write. To reiterate, FILEDISP=NEW affects only the first write to a given libref. For all subsequent writes to that libref, FILEDISP=NEW is ignored, and FILEDISP=OLD is assumed.

CAUTION:
Do not specify FILEDISP=NEW for the first write to a newly allocated libref that represents an existing sequential library. Doing so writes the new member at the beginning of the library and any other members in the library are lost.   [cautionend]
Remember, if you assigned the libref with a LIBNAME statement or function, you can reassign it with another LIBNAME statement or function. However, if you assigned the libref with a CMS FILEDEF command, you must use another FILEDEF command to change it.

Note:   The COPY procedure ignores FILEDISP= and CMS FILEDEF commands when a sequential library is specified as the destination of the copy. By default, the COPY procedure removes all members in the destination sequential library and writes new members into the beginning of the SAS file. To preserve existing members in a V6TAPE or later library, that library must be allocated using the host option DISP=MOD in the LIBNAME statement. For details, see Using the LIBNAME and FILENAME Options for Tape Processing.  [cautionend]

Examples


Chapter Contents

Previous

Next

Top of Page

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