Previous Page | Next Page

Using SAS Files

Accessing Sequential-Format Libraries in UNIX Environments


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.  [cautionend]


Reading and Writing SAS Files on Tape


Using a Staging Directory

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.)


Syntax of the LIBNAME Statement

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 tape-device-pathname must be a pathname for a tape device; it should be the name of the special file that is associated with the tape device. (Check with your UNIX system administrator for information.) The name must be enclosed in quotation marks. You cannot specify remote tape devices in the LIBNAME statement.

Example: Assign a Libref to the Tape Device

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


Why Use 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.


Syntax of the LIBNAME Statement

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.


Example: Creating a SAS Data Set Using a Named Pipe

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.

Previous Page | Next Page | Top of Page