| 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 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.
Under V7, three tape engines are supported: V5TAPE
(read-only),
V6TAPE, and V7TAPE. 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, for details about these
statements. The LIBNAME and FILENAME statements provide the following special
options particular to tape processing:
-
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
-
nonlabeled 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 the VOLID= option is used, the
VOL1 label on the tape is verified when a tape file is opened. When omitted,
no VOL1 check is made.
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
used as a libref in a LIBNAME statement or function or as the fileref in a
FILENAME statement.
The method 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 under CMS 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;
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
.
.
.
DMSTLM427I TAP1(181) EOV1 label read
Beginning DMSTVI EOV processing.
TAPE 0181 DETACHED
TAPE nnnn ATTACHED TO userid 0181
.
.
.
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 forward spaced unnecessarily.
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 the user issues 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 would be 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:
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 the data step 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.
![[cautend]](../common/images/cautend.gif)
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.
-
In the following SAS program, a SAS data file
is written on a nonlabeled tape that already contains one member of the same
SAS data library. Assume that the tape has already been mounted, but not rewound
and positioned. FILEDISP=OLD, the default, is in effect, so a TAPE REW command
is issued to position the tape before the first member in the library. The
DATA step writes the SAS data file on the tape after the existing SAS file.
cms tape rew;
libname favorite tape 'tap1';
data favorite.fruits;
set mylib.oranges;
run;
-
In the next example, a nonlabeled tape already
contains two external files. FILEDISP=NEW is specified for the SAS data set,
so the tape must be spaced forward. Otherwise, SAS would write over the existing
files.
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;
data lines
;
-
In the third example, a SAS data library is created
on a new tape that will have standard labels. The TAPE WVOL1 command writes
the volume label at the beginning of the tape, and the LIBNAME statement includes
LABEL=SL. FILEDISP=NEW is specified because a new library is created.
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;
-
In the next example, a SAS data file is read from
a tape with standard labels. The SAS data file is in the second file of the
tape.
libname tapefile tape 'tap2' label=sl 2;
proc print data=tapefile.monitor;
var weight age initbac baccnt chckdate;
id subject;
by dose;
run;
-
This next example illustrates the effects of specifying
FILEDISP=NEW in an output step other than the first output step following
the allocation of the libref. The library MYLIB is a tape format on disk library
which has five members named ONE, TWO, THREE, FOUR, and FIVE. The first data
step adds a new member, SIX, after member FIVE. The second data step writes
over member FOUR, and members FIVE and SIX are lost. The value of FILEDISP=NEW
is ignored and the default FILEDISP=OLD is assumed.
libname mylib tape 'a';
data mylib.six;
f=1;output;run;
data mylib.four (filedisp=new);
d=1;output;run;
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.