How to compress all data set in a library

Accepted Solution Solved
Reply
Regular Contributor
Posts: 161
Accepted Solution

How to compress all data set in a library

Ladies and Gentlemen:

I forgot to put the option (compress=yes) in my original code when creating dataset.  Is there a way to compress those SAS datasets in a batch mode?  There are too many of them to do it manually? 

I found this:

*----------------------------------------------------------------------;

* Copying datasets adding compression ;

*----------------------------------------------------------------------;

%let path=.;

options compress=yes ;

libname in "&path";

libname out "&path";

proc copy inlib=in outlib=out noclone datecopy memtype=data ;

run;

But I'm not sure this works or not, or it is the correct way for doing so.  Thanks -


Accepted Solutions
Solution
‎10-08-2013 10:27 PM
Respected Advisor
Posts: 4,173

Re: How to compress all data set in a library

Posted in reply to caveman529

Some code like below should do the job:

options compress=yes;

libname temp "c:\tests";
libname source (work);

proc datasets lib=temp kill nowarn nolist;
    copy inlib=work outlib=temp noclone datecopy memtype=data index=yes constraint=yes;
  run;
    copy inlib=temp outlib=work noclone datecopy memtype=data index=yes constraint=yes move;
  run;
quit;

libname temp clear;

View solution in original post


All Replies
Super User
Posts: 5,441

Re: How to compress all data set in a library

Posted in reply to caveman529

In 9.4 at least, SAS will stop you from doing that - you haven't tested yourself?

The simplest seems to have the tables compressed in alternate location.

Data never sleeps
Regular Contributor
Posts: 161

Re: How to compress all data set in a library

Many thanks for your help.  I found compress data reduce I/O quite a bit...

Solution
‎10-08-2013 10:27 PM
Respected Advisor
Posts: 4,173

Re: How to compress all data set in a library

Posted in reply to caveman529

Some code like below should do the job:

options compress=yes;

libname temp "c:\tests";
libname source (work);

proc datasets lib=temp kill nowarn nolist;
    copy inlib=work outlib=temp noclone datecopy memtype=data index=yes constraint=yes;
  run;
    copy inlib=temp outlib=work noclone datecopy memtype=data index=yes constraint=yes move;
  run;
quit;

libname temp clear;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 2563 views
  • 0 likes
  • 3 in conversation