1
votes

What are the best ways to zip SAS data sets? Below is the code that I have tried using SAS and Putty. In SAS, I did not get a log saying this was successful or not. I did get an ! exclamation point. In Putty, I also did not get any message if successful or not. What are the best and fastest ways to zip large data sets in SAS or Putty? Also, is there a way to do multiple data sets at once? Also, I think a log would be nice as well. Thank you!

SAS

LIBNAME ZIP '/server/department/analytics/data/PROJECT/';
x gzip /server/department/analytics/data/PROJECT/req1_txns1.sas7bdat;

Putty Unix

cd /server/department/analytics/data/PROJECT/
gzip req1_txns2.sas7bdat 
1
Does the zipping reason fall into 1) zipping for inter-system transfer, 2) zipping for reduced space while sporadically using data, 3) archive / backup, 4) other. Would data set or system options for compression be more appropriate ?Richard
Personally, I would consider creating some periodically-scheduled task – along the lines of Unix's logrotate and perhaps actually using*(!)* that very tool – which would comb the dataset directories looking for things to compress . . .Mike Robinson
In SAS, have you enabled the compress dataset option? This can save a significant amount of space without needing to zip. Additionally, the %squeeze() macro can reduce space even further. If it's possible to do this, I would recommend giving it a try.Stu Sztukowski

1 Answers

0
votes

I like (and highly recommend) Stu's comment on using %squeeze() to reduce disk space. But if you'd still like to zip the datasets you can use ods package to do the same refer.

An example of using it -

libname out '/project/path/here';

filename ds1 "%sysfunc(pathname(out))/sas_ds1.sas7bdat" recfm=n;
filename ds2 "%sysfunc(pathname(out))/sas_ds2.sas7bdat" recfm=n;
filename xl1 "%sysfunc(pathname(out))/xlfile1.xlsx" recfm=n; /*ensuring binary transfer*/

ods package (zip1) open nopf;  /*creates a folder in-memory*/
ods package (zip1) add file=ds1;
ods package (zip1) add file=ds2;
ods package (zip1) add file=xl1;
ods package (zip1) publish archive
    properties (archive_name="my_zipfile.zip" archive_path="%sysfunc(pathname(out))");
ods package (zip1) close; /*this saves it to disk*/

After executing these, your log should state that SAS is writing zip1 to the path mentioned. And, the my_zipfile.zip should get created in the folder you stated in the second last line publish archive properties ().