Using SAS Files |
Benefits and Limitations of Sequential Engines |
The sequential engines enable you to access libraries in sequential format on tape or disk. The sequential engines do not support indexing and compression of observations.
Note: Before using sequential engines, read the information about sequential libraries in SAS Language Reference: Concepts.
Reading and Writing SAS Files on Tape |
Use a staging directory so that 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.)
To access SAS 9.2 files on tape, you can specify the V9TAPE or TAPE engine in the LIBNAME statement:
LIBNAME libref V9TAPE 'tape-device-pathname'; |
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';
Writing Sequential Data Sets to Named Pipes |
You can send output to and read input from the operating environment by using named pipes. For example, you might want to compress a data set or send it to a tape management system without creating intermediate files.
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'; |
Because 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.
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 and then compressed and written to the data set. When SAS closes the data set, compression 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.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.