Sample 25199: Write a SASĀ® data set and compress it via a Unix command
Click on the Full Code tab for an example that demonstrates how a SAS data set
can be compressed via a Unix command.
Important: This example is meant to be used with
Sample 25214, which
demonstrates how to read a SAS data set that has been 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 compress command. */
/* It has to be done this way, or it will not work. */
/* The filename pipe forks another process and executes the */
/* Unix command. The Unix compress command is reading from */
/* the read end of the named pipe, then redirecting the output */
/* to the file. Be sure to place this in the background, or the */
/* process will hang. */
/* BECAUSE OF THE WAY UNIX NAMED PIPES FUNCTION, IN ORDER TO */
/* USE THE UNCOMPRESS EXAMPLE, THE COMPRESSED FILE MUST BE */
/* CREATED USING THIS EXAMPLE. */
libname fargo 'piper';
filename nwrpipe pipe 'compress < piper > sasds.Z &';
/* This DATA step references the filename pipe, then forks */
/* the process to execute the Unix command. */
data _null_;
infile nwrpipe;
run;
/* The DATA step writes to the write end of the named pipe */
data fargo.a;
do i = 1 to 1000;
j = i * 3.14;
output;
end;
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: | Common Programming Tasks ==> Reading and Writing External Data
|
Date Modified: | 2008-06-18 14:31:41 |
Date Created: | 2005-02-10 12:52:37 |
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 |
64-bit Enabled AIX | n/a | n/a |
Tru64 UNIX | n/a | n/a |