Monday, November 26, 2012

to gzip output using FIFO

Generally SAS programmer make an output file and then run "gzip" command using "X", "CALL SYSTEM" or "%SYSEXEC". Actually, we can gzip output on the fly.
See below:
x "mknod pipe&sysjobid p";

filename cmd pipe "gzip < pipe&sysjobid 
> sashelp.DAT.gz &";

data _null_;
 infile cmd;
 stop;
run;

data _null_;
 file "pipe&sysjobid";

 retain header;
 if missing(header) then do;
  put "NAME|SEX";
  header = 1;
 end;

 set sashelp.class;
 put name +(-1) '|' sex;
run;
filename cmd clear;

x "rm pipe&sysjobid";

No comments: