Chapter Contents |
Previous |
Next |
SAS Companion for UNIX Environments |
Note: Before
using sequential engines, read the information about sequential data libraries
in
SAS Language Reference: Dictionary.
Reading and Writing SAS Files on Tape |
You can write
SAS files directly to tape using the TAPE engine;
however, it is more efficient to use a staging directory so that the files
can be processed directly from disk. You can use the UNIX
tar
command to move SAS data sets between the
staging directory and tape. (Do not use the UNIX
cp
command.)
A SAS library on tape can contain one or more SAS data sets; however, only one SAS data set from a given library on tape can be accessed at any given point in a SAS job.
To access Version 8 SAS files on tape, you can specify the V8TAPE or TAPE engine in the LIBNAME statement:
LIBNAME libref V8TAPE 'tape-device-pathname'; |
Multi-volume tape libraries are supported if you specify the TAPECLOSE=LEAVE system option when you start your SAS session.
For example, the following LIBNAME statement assigns
the libref SEQ2 to the
/dev/tape2
tape device. Because the
tape device is specified, the engine does not have to be specified.
libname seq2 '/dev/tape2';
Reading and Writing Transport Formats on Tape |
Transport formats on tape are handled in a manner similar to external files. Read Processing Files on TAPE before continuing with this topic.
For example, the following SAS statements issue the
UNIX
mt
command to rewind
the tape and create a transport file using the xport engine and PROC CPORT:
x 'mt -t /dev/rmt/0mn rewind'; libname tranfile xport '/dev/rmt/0mn'; proc cport library=sasuser file=tranfile; run;The following statements import the transport file into the WORK data library:
x 'mt -t /dev/rmt/0mn rewind'; libname tranfile xport '/dev/rmt/0mn'; proc cimport infile=tranfile library=work; run;
Writing Sequential Data Sets to Named Pipes |
You can read from and write to named pipes from within your SAS session by specifying the pipe name in the LIBNAME statement:
LIBNAME libref <TAPE> 'pipename'; |
Since you cannot position a pipe file, SAS uses the TAPE engine to ensure sequential access. You do not have to specify the engine name; TAPE is assumed.
For example, suppose you want to create a SAS data set
and compress the data set without creating an intermediate, uncompressed data
set. Create a named pipe (such as
mypipe
) and enter the
compress
command:
mknod mypipe p compress <mypipe >sasds.Z
In your SAS session, assign a libref to the pipe and begin writing to the data set:
libname x 'mypipe'; data x.a; ...more SAS statements... output; run;
The data is sent to
mypipe
, compressed, and
written to the data set. When SAS closes the data set, the compress finishes,
and you have a compressed, sequential data set in
sasds.Z
.
If you begin writing to a named pipe before the task
on the other end (in this case, the
compress
command) begins
reading, your SAS session will be suspended until the task begins to read.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.