/* metasets macro. Accesses the SAS datasets in a directory and creates a SAS meta-dataset with information about them. It creates "place holders" for more variables than can be defined using proc contents info, which can be entered manually or via some other automated means. jgb 12.27.02 -- Begin coding. TO BE CONTINUED */ /********************************************************************/ /* BEGIN MACRO DEFINITION */ /********************************************************************/ %macro metasets( /* Create metadata dataset describing all datasets in a directory (space) */ datadir=%str(/pub/data), /* the root directory. libref, /* positional. if 8 or fewer characters then assumed to be an existing libref. otherwise, assumed to be a physical name (dsn) and the dummy libref ssdl is defined and associated with this name. the engine parm can be used to specify an engine spec when issuing the libname but is usually not required. */ orderby=, /* to sort the report in other than standard memname order specify one or more variables for the order by clause */ engine=, /* engine spec may be required when issuing libname */ dsn=, /* if libname already defined but you want to see dsn in the 4th line of report title. important: do *not* enclose this value in quotes */ saywhen=1, /* use saywhen=0 to suppress log msg re revision date */ ); /* end */ %if &saywhen %then %do; %put %str( ); %put ***************************************************************; %put * contdir macro rev &revdate begin execution *; %put ***************************************************************; %put %str( ); %end; %if %length(&libref) gt 8 %then %do; %let dsn=&libref; %let libref= ; %end; %if %quote(&dsn) ne %str() and &libref eq %str() %then %do; *--user specified a dsn but not a libref. generate libname stmt--; libname ssdl &engine "&dsn" access=readonly; *--mod 12/2001--; %let libref=ssdl; %end; %*--2-18-99. save and restore label and fmterr options-----; %let fmterr=%sysfunc( getoption(fmterr)); %let labelopt=%sysfunc( getoption(label)); %put &fmterr &labelopt; options nofmterr; proc contents data=&libref.._all_ noprint out=_contout; run; options nolabel; proc sql; %if &dsn ne %str() %then %let libref=&dsn; title4 "contents summary report of &libref sas data library"; create table _contdir as select distinct memname, memlabel, nobs, count(*) as nvars, sum(length) as obslen, sum(length)*nobs/1000 as kbytes format=comma9. , crdate as created format=datetime7. , modate as lastmod format=datetime10. , engine , idxcount as nx format=2. from _contout group by memname %if &orderby ne %str() %then %do; order by &orderby %end; ; proc print data=_contdir d; run; title4 ; %*---reset title-; options &fmterr &labelopt; %*--reset system options-; %mend contdir;