Accessing Sequential-Format Data Libraries in UNIX Environments


Benefits and Limitations of Sequential Engines

The sequential engines enable you to access data 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 data libraries in SAS Language Reference: Dictionary .

Reading and Writing SAS Files on Tape

Introduction to SAS Libraries on Tape

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.

Benefit of using a Staging Directory

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

Syntax of the LIBNAME Statement

To access SAS 9.1 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 associated with the tape device. (Check with your system administrator for details.) The name must be enclosed in quotation marks. You cannot specify remote tape devices in the LIBNAME statement.

Example: Assigning 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'; 

Accessing Multi-Volume Tape Libraries

Multi-volume tape libraries are supported if you specify the TAPECLOSE=LEAVE system option when you start your SAS session.

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 in UNIX Environments" on page 149 before continuing with this topic.

Example: Transporting a File From Tape to the Work Library

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 from tape 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

Why Use Named Pipes?

You can send output to and read input from the operating system 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 ';

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.

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




SAS 9.1 Companion for UNIX Environments
SAS 9.1 Companion For Unix Enivronments
ISBN: 1590472101
EAN: 2147483647
Year: 2004
Pages: 185
Authors: SAS Institute

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net