Sample 25206: SAMPLE: Create/Read a Unix compressed file from SAS
This example uses gzip to create a Unix compressed file.
The file is stored in SAS transport format.
The example then uses gunzip to read the Unix compressed file.
| Type: | Sample |
| Topic: | Common Programming Tasks ==> Reading and Writing External Data ==> EFI
|
| Date Modified: | 2005-03-19 03:02:37 |
| Date Created: | 2005-02-10 13:09:04 |
Operating System and Release Information
| Product Family | Product | Host | Starting Release | Ending Release |
| 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 |
/* In this sample, gzip/gunzip are used to read and write
the compressed file, but you could just as easily use compress and
uncompress (or your favorite compression utility) to do this. */
/* Be sure to place the gzip command in the background, or the
processes will hang. */
filename mkpipe pipe 'mknod $HOME/piper p';
data _null_;
infile mkpipe;
run;
filename cmpres pipe 'gzip <$HOME/piper >$HOME/file.Z &';
filename foo '$HOME/piper';
libname foo xport;
data _null_;
infile cmpres;
run;
data foo.compress;
do i=1 to 100;
x=ranuni(i);
output;
end;
run;
filename rmpipe pipe 'rm $HOME/piper';
data _null_;
file rmpipe;
run;
/* This section of the example shows how to use the gunzip UNIX command to read a UNIX */
/* compressed file. */
/* The file is stored in SAS transport format. It must be done this way in order to */
/* read and write from the UNIX named pipe. */
/* Be sure to place the gunzip command in the background, or the processes will hang. */
filename mkpipe pipe 'mknod $HOME/piper p';
filename rmpipe pipe 'rm $HOME/piper';
filename uncmpres pipe 'gunzip >$HOME/piper <$HOME/file.Z &';
filename foo '$HOME/piper';
libname foo xport;
data _null_;
infile mkpipe;
run;
data _null_;
file uncmpres;
run;
proc print data=foo.compress;
run;
data _null_;
file rmpipe;
run;
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.
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.