Sample 48809: Determine whether SAS data sets in a library are compressed, and if they are not, automatically compress the SAS data set
Use PROC SQL Dictionary tables to return the names of SAS data sets in the SAS library. The WORK library is used in this example, but you can use any SAS data library. The variable created from the PROC SQL Dictionary tables is called COMPRESS that has a value of either NO (no compression) or CHAR/YES/BINARY if compression exists.
Then, in a DATA _NULL_ step read the SAS data set created from PROC SQL Dictionary tables, and create macro variables with the names of the SAS data sets that had a value of NO for the COMPRESS variable along with a count of the number of SAS data set that meet the criteria. Finally, execute a macro that compresses the SAS data set automatically if no compression exists.
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.
/* Create some test data sets - one, two and three in the WORK library */
data one(compress=yes);
do i= 1 to 10000000;
set sashelp.class;
output;
end;
run;
data two;
do i=1 to 100;
output;
end;
run;
data three;
set two;
a='apple';
b='boy';
c='cat';
x=i*2;
y=i/2;
z=x*y;
run;
/* 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 = 'WORK' ;
quit;
/* 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;
if compress='NO' then do;
i+1;
call symputx('n'||trim(left(put(i,8.))),memname);
end;
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 */
%macro test;
%do i=1 %to &count;
data work.&&n&i(compress=char);
set work.&&n&i;
run;
%end;
%mend test;
/* invoke the macro */
%test
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.
Type: | Sample |
Topic: | SAS Reference ==> System Options ==> COMPRESS=
|
Date Modified: | 2013-01-03 09:37:04 |
Date Created: | 2012-12-21 13:24:15 |
Operating System and Release Information
SAS System | Base SAS | z/OS | | |
Z64 | | |
OpenVMS VAX | | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | | |
Microsoft Windows XP 64-bit Edition | | |
Microsoft® Windows® for x64 | | |
OS/2 | | |
Microsoft Windows 8 Pro | | |
Microsoft Windows 95/98 | | |
Microsoft Windows 2000 Advanced Server | | |
Microsoft Windows 2000 Datacenter Server | | |
Microsoft Windows 2000 Server | | |
Microsoft Windows 2000 Professional | | |
Microsoft Windows NT Workstation | | |
Microsoft Windows Server 2003 Datacenter Edition | | |
Microsoft Windows Server 2003 Enterprise Edition | | |
Microsoft Windows Server 2003 Standard Edition | | |
Microsoft Windows Server 2003 for x64 | | |
Microsoft Windows Server 2008 | | |
Microsoft Windows Server 2008 for x64 | | |
Microsoft Windows Server 2012 | | |
Microsoft Windows XP Professional | | |
Windows 7 Enterprise 32 bit | | |
Windows 7 Enterprise x64 | | |
Windows 7 Home Premium 32 bit | | |
Windows 7 Home Premium x64 | | |
Windows 7 Professional 32 bit | | |
Windows 7 Professional x64 | | |
Windows 7 Ultimate 32 bit | | |
Windows 7 Ultimate x64 | | |
Windows Millennium Edition (Me) | | |
Windows Vista | | |
Windows Vista for x64 | | |
64-bit Enabled AIX | | |
64-bit Enabled HP-UX | | |
64-bit Enabled Solaris | | |
ABI+ for Intel Architecture | | |
AIX | | |
HP-UX | | |
HP-UX IPF | | |
IRIX | | |
Linux | | |
Linux for x64 | | |
Linux on Itanium | | |
OpenVMS Alpha | | |
OpenVMS on HP Integrity | | |
Solaris | | |
Solaris for x64 | | |
Tru64 UNIX | | |