Chapter Contents |
Previous |
Next |
COPY |
CMS specifics: | use of LABEL= option |
Copying Members to Sequential Libraries | |
Types of Label Processing | |
LABEL=LABOFF Processing | |
LABEL=NL Processing | |
LABEL=SL Processing | |
See Also |
Copying Members to Sequential Libraries |
Appending new members without checking for duplicates means that the destination library can have two or more members with the same name after the copy. Only the first member in the library will be accessed by SAS. To ensure that all members can be accessed by SAS, use the EXCLUDE statement in the COPY procedure or, after the COPY procedure, use the REMOVE or RENAME statements in the DATASETS procedure. For further information, see SAS Procedures Guide.
For further information on sequential tape processing, see Working with SAS Files on Tape.
Types of Label Processing |
The SAS System under CMS follows the defaults
for the
CMS FILEDEF command, and therefore the default for this option is LABEL=LABOFF.
However, to reduce the risk of error, SAS Institute recommends using LABEL=NL
for nonlabeled tapes. Always use LABEL=SL for labeled tapes. SAS Institute
also recommends avoiding the use of the CMS FILEDEF command with SAS and instead
using the LIBNAME statement.
After SAS reads or writes a tape library, the tape is positioned just after the end-of-file tape mark for that tape library. An exception is that if an error occurs during tape I/O, the tape remains positioned at the point of the error, and not past the tape mark. Normal output is terminated with a single tape mark. After your final output, you should issue CMS TAPE WTM to ensure that the tape ends with a double tape mark.
If you write to a tape library and then want to append to the same tape library, you must issue CMS TAPE BSF so that the tape mark that ends the first output is overwritten. Otherwise, this tape mark separates the two outputs into two tape libraries. When you write data to a tape, everything from that point that was formerly on the tape becomes unusable. Therefore, take extreme care in positioning the tape.
To reread a tape library you have just read or written, manually position the tape to the desired location. To do this, reissue the LIBNAME statement, and then issue CMS TAPE commands to position the tape.
Some tape processing examples using LABEL=LABOFF include
/* label=laboff default */ /* insure tape position */ libname tapeout 'tap1'; CMS tape rew; /* copy SAS data library */ proc copy in=lib1 out=tapeout; /* from lib1 to tape */ run; /* extra tape mark at end */ CMS tape wtm;
/* label=laboff default */ libname tapeout 'tap1'; /* insure tape position */ CMS tape rew; /* copy SAS data library */ proc copy in=lib1 out=tapeout; /* from lib1 to tape */ run; /* position tape before */ CMS tape bsf 1; /* end of file mark */ /* copy SAS data library */ proc copy in=lib2 out=tapeout; /* from lib2 to the */ run; /* same tape library */ /* extra tape mark at end */ CMS tape wtm;
/* label=laboff default */ libname tapeout 'tap1'; /* insure tape position */ CMS tape rew; /* use FSF N to forward */ CMS tape fsf 1; /* past N existing files */ /* copy SAS data library */ proc copy in=lib2 out=tapeout; /* from lib2 to a */ run; /* separate tape library */ /* extra tape mark at end */ CMS tape wtm;
/* label=laboff default */ libname tapeout 'tap1'; /* insure tape position */ cms tape rew; /* use fsf N to forward */ cms tape fsf 1; /* past N existing files */ cms tape bsf; /* position for appending */ /* append SAS data library*/ proc copy in=lib3 out=tapeout; /* from lib3 to tape */ run; /* extra tape mark at end */ cms tape wtm;
After SAS reads or writes a tape library, the tape is positioned just after the end-of-file tape mark for that tape library. Output is terminated with a double tape mark; you do not need to write an additional tape mark.
If you do output to a tape library and then want to append to the same tape library, simply continue to use the existing libref. Do not reissue the LIBNAME statement. Likewise, once you have read from or written to a tape library, if you then want to reread it, no special steps are required.
If you want to use PROC COPY to append to a tape library that was written in a previous SAS session or for which the libref has been deassigned, you must do something in the current SAS session to cause SAS to read the entire existing tape library (for example, PROC CONTENTS). This step appends subsequent output to that tape library to the end of the physical sequential file. If you omit this step, output to that tape library overwrites the existing physical sequential file.
In one special case, CMS TAPE commands are needed with LABEL=NL. To initialize a new tape for LABEL=NL processing, you must issue
cms tape rew; cms tape wtm 2;
Otherwise, the tape could run off the end.
Some tape processing examples using LABEL=NL include
/* insure tape position */ cms tape rew; /* initialize tape */ cms tape wtm 2; /* specify file 1 */ libname tapeout 'tap1' label=nl 1; /* copy SAS data library */ proc copy in=lib1 out=tapeout; /* from lib1 to tape */ run;
/* insure tape position */ cms tape rew; /* initialize tape */ cms tape wtm 2; /* specify file 1 */ libname tapeout 'tap1' label=nl 1; /* copy lib1 to tape */ proc copy in=lib1 out=tapeout; /* copy lib2 to the */ proc copy in=lib2 out=tapeout; /* same tape library */ run;
/* specify file 2 */ libname tapeout 'tap1' label=nl 2; /* copy SAS data library */ proc copy in=lib2 out=tapeout; /* from lib2 to a */ run; /* separate tape library */
/* specify file 1 */ libname tapeout 'tap1' label=nl 1; /* read the library */ proc contents data=tapeout._all_ nods; run; /* append SAS data library*/ proc copy in=lib3 out=tapeout; /* from lib3 to tape */ run;
Note: PROC CONTENTS is used to force
SAS to load the tape's library structure so that PROC COPY will append rather
than overwrite.
With the LABEL=SL n option of the LIBNAME statement, you specify the sequential number of the file on the tape. For example, LABEL=SL 3 causes the third sequential file to be opened. You do not need to use the CMS TAPE command to position the tape; when SAS opens the sequential file, CMS automatically rewinds the tape and positions it to the specified file. Because the tape is rewound during positioning, it will be positioned correctly regardless of the prior tape position.
If you do output to a tape library and then want to append to the same tape library, continue to use the existing libref. Do not reissue the LIBNAME statement. Likewise, once you have read from or written to a tape library, if you then want to reread it, no special steps are required.
If you want to use PROC COPY to append to a tape library that was written in a previous SAS session, or for which the libref has been deassigned, you must cause SAS to read the entire existing tape library (for example, PROC CONTENTS). This step appends subsequent output to that tape library to the end of the physical sequential file. If you omit this step, output to that tape library overwrites the existing physical sequential file.
In one special case, you may need CMS TAPE commands with LABEL=SL. To initialize a new tape for LABEL=SL processing, you must submit the following statements:
cms tape rew; cms tape wvol1 volid;
However if your tape is cataloged in a tape management system, this step has probably been done for you automatically.
Some tape processing examples using LABEL=SL include
/* specify file 1 */ libname tapeout 'tap1' label=sl 1 /* and identify VOLID */ volid=V00001; /* copy SAS data library */ proc copy in=lib1 out=tapeout; /* from lib1 to tape */ run;
/* specify file 1 */ libname tapeout 'tap1' label=sl 1 /* and identify VOLID */ volid=V00001; /* copy lib1 to tape */ proc copy in=lib1 out=tapeout; /* copy lib2 to the */ proc copy in=lib2 out=tapeout; /* same tape library */ run;
/* specify file 2 */ libname tapeout 'tap1' label=sl 2 /* and identify VOLID */ volid=V00001; /* copy SAS data library */ proc copy in=lib2 out=tapeout; /* from lib2 to tape */ run;
/* specify file 1 */ libname tapeout 'tap1' label=sl 1 /* and identify VOLID */ volid=V00001; proc contents data=tapeout._all_ nods; /* read the library */ run; /* append SAS data library*/ proc copy in=lib3 out=tapeout; /* from lib3 to tape */ run;
Note: PROC
CONTENTS is used to force SAS to load the tape's library structure so that
PROC COPY will append rather than
overwrite.
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.