I had to do an analysis once on the volume of sas datasets our team managed and how many of those were compressed. I wrote a program that traversed the directory tree of our team's space on the sas grid. Basically, for each directory a libref was created. Then the corresponding dataset info was extracted from dictionary.tables and appended to a master dataset. The following macro gets certain information about all of the sas datasets in a particular directory. %macro get_dsn_info (dir);
libname _lib "&dir";
proc sql;
create table _tmp as
select "&dir" as dir length=200,
memname, modate, filesize, compress, pcompress, nobs, nvar
from dictionary.tables
where libname = '_LIB'
and memtype = 'DATA';
quit;
* append dataset info to master dataset;
proc append base=master data=_tmp;
run;
libname _lib clear;
%mend; This is the main code that repeatedly calls the macro. I work in a Linux environment, but this could easily be adapted to Windows. in the code i offer a suggested command to get a list of directories. %let hi_lvl_dir = /some/dir;
proc datasets lib=work nolist nowarn;
delete master;
quit;
* linux - get a list of all directories and subdirectories;
filename cmd pipe "find &hi_lvl_dir -not \( -path &hi_lvl_dir/.snapshot
-prune \) -type d 2>/dev/null";
* windows (?);
*filename cmd pipe "dir &hi_lvl_dir /ad /b /s";
* loop through all directories in directory tree;
data _null_;
infile cmd;
input dir &:$200.;
* repeatedly call the macro for each directory;
cmd = cats('%get_dsn_info(', dir, ');');
call execute (cmd);
run; Works like a charm.
... View more