Sample 25214: Read a SASĀ® data set that has been compressed via a Unix command
Click on the Full Code tab for an example that demonstrates how
a SAS data set that has been compressed using a Unix utility
can be read directly, without intermediate steps.
Important: This example is dependent upon
Sample 25199,
which demonstrates how to write a SAS data set compressed using a Unix command.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* Use the X statement to create the named pipe "piper". */
x 'mknod piper p';
/* Assign the libref to the named pipe, then use the FILENAME */
/* pipe to assign the fileref to the Unix uncompress command. */
/* It has to be done this way or it will not work. */
/* The FILENAME pipe, when referenced, will fork another process, */
/* then execute the Unix command. The Unix uncompress command */
/* gets its input from the compressed file, then writes the output */
/* to the write end of the named pipe. Be sure to issue the */
/* command in the background or the process will hang. */
/* IN ORDER TO USE THIS EXAMPLE TO READ IN A UNIX COMPRESSED */
/* SAS DATA SET, THE SAS DATA SET MUST HAVE BEEN CREATED USING */
/* THE COMPRESS EXAMPLE. BECAUSE OF THE WAY PIPES FUNCTION, */
/* THE EXISTING SAS DATA SET CANNOT BE SIMPLY COMPRESSED OUTSIDE */
/* OF SAS THEN READ IN USING THIS EXAMPLE. THE UNIX COMPRESSED */
/* FILE MUST BE CREATED USING SAS. */
libname fargo 'piper';
filename nwrpipe pipe ' uncompress >piper <sasds.Z &';
/* This DATA step references the FILENAME pipe, then forks */
/* the process to execute the Unix command. */
data _null_;
infile nwrpipe;
run;
/* This DATA step reads from the read end of the named pipe, then */
/* creates a SAS data set. */
data new;
set fargo.a;
put _all_;
run;
/* Use the X statement to remove the named pipe. */
x 'rm piper';
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Type: | Sample |
Topic: | SAS Reference ==> DATA Step SAS Reference ==> Statements ==> File-handling ==> SET SAS Reference ==> Statements ==> Data Access ==> FILENAME
|
Date Modified: | 2008-06-18 13:11:05 |
Date Created: | 2005-02-10 13:23:36 |
Operating System and Release Information
SAS System | Base SAS | 64-bit Enabled Solaris | n/a | n/a |
64-bit Enabled HP-UX | n/a | n/a |
ABI+ for Intel Architecture | n/a | n/a |
AIX | n/a | n/a |
HP-UX | n/a | n/a |
HP-UX IPF | n/a | n/a |
Linux | n/a | n/a |
Solaris | n/a | n/a |
Tru64 UNIX | n/a | n/a |
64-bit Enabled AIX | n/a | n/a |