I found the macro, Sample 48809: Determine whether SAS data sets in a library are compressed, and if they are not, automatically compress the SAS data set, for compressing a library. I added a couple of improvements:
1. Pick only DATA memtypes (drop view, for example).
2. Pick only uncompressed members.
3. Only continue if at least one record was found.\
I've thought of another improvement, which would be to compress the dataset and make sure the compressed dataset is smaller than the uncompressed datset (sometimes they aren't) and then don't save the compressed version if it's larger.
/* compress all uncompress datasets within a library */
%macro compress_library(libname);
%let libname = %upcase(&libname);
/* Use the DICTIONARY.TABLES to obtain the name of the SAS data set (memname) and whether the SAS
data set is compressed (COMPRESS) and store in a SAS data set, INFOSQL */
proc sql;
create table infosql as
select memname, compress
from dictionary.tables
where libname = "&libname" and compress='NO' and memtype='DATA';
quit;
%if &SYSNOBS > 0 %then %do;
/* Use DATA _NULL_ step to create 2 macro variables - one is the name of the SAS data set that is
not compressed and the other the number of SAS data sets not compressed */
data _null_;
set infosql end=last;
i+1;
call symputx('n'||trim(left(put(i,8.))),memname);
if last then
call symputx('count',i);
run;
/* Run the macro DO loop from 1 to &count to compress each SAS data set not compressed in the SAS
data library */
%do i=1 %to &count;
data &libname..&&n&i(compress=yes);
set &libname..&&n&i;
run;
%end;
%end;
%mend compress_library;
... View more