|SAS Companion for the CMS Environment|
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.
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.
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:
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.
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.
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.
/* 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.
/* 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.
/* 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.
/* 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.
/* 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:
libname mytaplib tape;
libname mytaplib tape 'tap1';
|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.
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.
cms tape rew; libname favorite tape 'tap1'; data favorite.fruits; set mylib.oranges; run;
cms tape rew; cms tape fsf 2; libname fall89 tape 'tap1'; data fall89.scores (filedisp=new); input student $11. test1 3.0 test2 3.0 test3 3.0 test4 3.0; cards; ...more data lines... ;
cms tape rew; cms tape modeset (den 6250; cms tape wvol1 vm6111; libname bank tape 'tap1' label=sl 1; data bank.ncyield (filedisp=new); set agri.ncyield; run;
libname tapefile tape 'tap2' label=sl 2; proc print data=tapefile.monitor; var weight age initbac baccnt chckdate; id subject; by dose; run;
libname mylib tape 'a'; data mylib.six; f=1; output; run; data mylib.four (filedisp=new); d=1; output; run;
Top of Page
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.