Chapter Contents |
Previous |
Next |
SAS Companion for the OpenVMS Operating Environment |
Note: You cannot use wildcards in tape specifications,
nor can you use concatenated tape specifications.
DCL Commands for Tape Access |
$ MOUNT device-name volume-label |
If the tape is unlabeled, then you must include the /FOREIGN qualifier and the device name. The syntax of the MOUNT command for an unlabeled tape is
$ MOUNT/FOREIGN device-name |
You do not need to use volume-label when requesting an unlabeled tape.
If you are requesting an unlabeled tape, you can issue the following form of the MOUNT command, which tells the computer operator which tape to mount:
$ MOUNT/ASSIST/COMMENT=
|
If you are writing or reading records of a different length than the default block size, you can use the /BLOCKSIZE= qualifier to specify the block size. For example, in the following form of the MOUNT command, xxxx specifies the appropriate block size for an unlabeled tape:
$ MOUNT/FOREIGN/BLOCKSIZE=
|
After you issue the MOUNT command for a labeled or unlabeled tape, your keyboard locks until the MOUNT command executes (that is, until the operator mounts the tape). This command is required.
In each of these commands, device-name can be either the name of a tape drive at your site (for example, MUA0:) or a logical pointing to the tape drive.
After you issue commands to request the device and tape volume, use the DCL DEFINE command, the SAS FILENAME statement, or the FILENAME function to associate an OpenVMS logical name or SAS fileref with the external file on tape. For a labeled tape, specify a file in one of the following two forms:
For an unlabeled tape, specify a file in one of the following two forms:
You can also use the SAS X statement to issue the DEFINE command.
The OpenVMS logical name or SAS fileref that is assigned to the tape device is then used as the file specification in the INFILE or FILE statement.
Note: In these examples, it is assumed that the OpenVMS logical name definition for tapedevice includes a colon in the device specification, such as the following:
$ DEFINE TAPEDEVICE MUA0:
If your OpenVMS logical name definition does not include a colon, then you must specify the colon when you use TAPEDEVICE, as in the following:
filename fileref 'tapedevice:';
INITIALIZE |
ALLOCATE |
MOUNT |
This order differs from the order that you use when you issue the same commands from the DCL prompt.
If you do not use this order, and you allocate the tape before you initialize it, a message warns you that the device has already been allocated to another user when you try to initialize the tape.
When you issue the tape-access commands from the DCL prompt, specify them in the following order:
ALLOCATE |
INITIALIZE |
MOUNT |
$ ALLOCATE TAPEDEVICE $ INITIALIZE TAPEDEVICE TAPELIB $ MOUNT/INITIALIZE=CONTINUATION TAPEDEVICE TAPELIB $ SAS . . . more SAS statements . . .
The /INITIALIZE=CONTINUATION qualifier guarantees that the appropriate number is added to the label as the OpenVMS system mounts the subsequent volumes. For example, the following MOUNT command first creates a tape labeled MYTAPE. Subsequent tapes are labeled MYTA02, MYTA03, MYTA04, and so on:
$ MOUNT/INITIALIZE=CONTINUATION $2$MUA2: MYTAPE
When you issue a request to mount the next relative volume, the operator issues the reply with the /INITIALIZE_TAPE=request-number option. For example, if you issue the following request:
Request 69 from user SMITH. Mount relative volume MYTA02 on $2$MUA2:the operator performs the following steps:
$ REPLY/INITIALIZE_TAPE=69which sends the following message to user SMITH:
Mount request 69 satisfied by operator
As this example illustrates, some coordination is required between the user and the operator when multivolume tapes are used. Contact your system manager for more information about this topic.
Writing to a Labeled Tape |
$ ALLOCATE TAPEDEVICE $ INITIALIZE TAPEDEVICE LABEL1 $ MOUNT TAPEDEVICE LABEL1 $ DEFINE OUTTAPE TAPEDEVICE:EXPGIFTS.DAT $ SAS . . . notes and messages to SAS log . . . 1? data _null_; 2? input gift $ price; 3? file outtape; 4? if price>100 then 5? put gift price; 6? datalines; 7> watch 250.00 8> clown 35.31 . . . more data lines . . . 15> ; . . . notes and messages to SAS log . . . 16? x 'dismount tapedevice'; 17? x 'deallocate tapedevice'; 18?
This program writes the file EXPGIFTS.DAT to the tape that is identified by the label LABEL1. (The tape is referenced by the fileref OUTTAPE in the FILE statement.) After the write operation, the tape remains positioned at the end of the first file, ready to write another file. When you issue the DISMOUNT and DEALLOCATE commands, the tape is rewound and physically unloaded, and the drive and tape are released from your SAS session.
The default block size for an ANSI-labeled tape is 2,048 bytes.
Writing to an Unlabeled Tape |
When you are writing to an unlabeled tape, you must use the /FOREIGN qualifier in the MOUNT command:
$ MOUNT/FOREIGN TAPEDEVICE
You must also use special values for the RECFM= and LRECL= options in the FILE statement, as shown in the following example:
$ ALLOCATE TAPEDEVICE $ INITIALIZE TAPEDEVICE $ MOUNT/FOREIGN TAPEDEVICE $ DEFINE OUTTAPE TAPEDEVICE $ SAS . . . notes and messages to SAS log . . . 1? data _null_; 2? input gift $ price; 3? file outtape recfm=d lrecl=80; 4? if price>100 then 5? put gift price; 6? datalines; 7> watch 250.00 8> clown 35.31 . . . more data lines . . . 15> ; . . . notes and messages to SAS log . . . 16? x 'dismount outtape'; 17? x 'deallocate outtape'; 18?
The default block size for an unlabeled tape is 512 bytes. If you want to write a record that is longer than the default block size, you must increase the block size by using the /BLOCKSIZE qualifier in the MOUNT command. For example, the following command increases the block size to 8000 bytes for an unlabeled tape:
$ MOUNT/FOREIGN/BLOCKSIZE=8000 TAPEDEVICE LABEL1
If you attempt to write a record that is longer than the block size, you receive the following error message:
ERROR: Tape block size less than LRECL specified.
To write to an unlabeled tape from the DATA step, you must indicate the tape format by using RECFM=D. If you do not use RECFM=D for this type of access, the results are unpredictable.
You must also use the LRECL= option to indicate the length of each record. If the records that you are writing are variable-length records, then use a value for the LRECL= option that is the maximum record length. The minimum LRECL= value is 14. This minimum value is the only restriction on the LRECL= value for unlabeled tapes.
Reading from a Labeled Tape |
$ ALLOCATE TAPEDEVICE $ MOUNT TAPEDEVICE LABEL1 $ DEFINE INTAPE TAPEDEVICE:EXPGIFTS.DAT $ SAS . . . notes and messages to SAS log . . . 1? data expenses; 2? infile intape; 3? input gift $ price; 4? run; . . . notes and messages to SAS log . . . 5? x 'dismount tapedevice'; 6? x 'deallocate tapedevice'; 7?
The DATA step in this example reads a file named EXPGIFTS.DAT, which is located on the tape identified by the label LABEL1. (The file is referenced by the fileref INTAPE in the INFILE statement.) After the read operation, the tape is positioned at the start of the next file.
Reading from an Unlabeled Tape |
Here are two ways of positioning a tape to the correct file:
The following example illustrates using a null DATA step to skip the first file on an unlabeled tape so that the second DATA step can read the next file:
$ ALLOCATE TAPEDEVICE $ MOUNT/FOREIGN TAPEDEVICE $ DEFINE MYTAPE TAPEDEVICE $ SAS . . . notes and messages to SAS log . . . 1? data _null_; 2? infile mytape recfm=d lrecl=80; 3? input; 4? run; . . . notes and messages to SAS log . . . 5? data prices; 6? infile mytape recfm=d lrecl=80; 7? input name $ x y z; 8? prod=x*y; 9? if prod<z then output; 0? run; . . . notes and messages to SAS log . . . 5? x 'dismount mytape'; 6? x 'deallocate mytape'; 7?
The next example illustrates how to read the second file from the tape that is referenced by the OpenVMS logical name MYTAPE by using the SET MAGTAPE command with the /SKIP=FILES: n qualifier:
$ ALLOCATE TAPEDEVICE $ MOUNT/FOREIGN TAPEDEVICE $ DEFINE MYTAPE TAPEDEVICE $ SAS . . . notes and messages to SAS log . . . 1? x 'set magtape mytape/skip=files:1'; 2? data prices; 3? infile mytape recfm=d lrecl=80; 4? input name $ x y z; 5? prod=x*y; 6? if prod<z then output; 7? run; . . . notes and messages to SAS log . . . 8? x 'dismount mytape'; 9? x 'deallocate mytape'; 10?
To read from an unlabeled tape from the DATA step, you must indicate the tape format by using RECFM=D. If you do not use RECFM=D for this type of access, the results are unpredictable.
You must also use the LRECL= option to indicate the length of each record. If the records that you are accessing are variable-length records, then use a value for the LRECL= option that is the maximum record length. The minimum LRECL= value is 14. This minimum value is the only restriction on the LRECL= value for unlabeled tapes.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.