Create a directory-level output data set from PROC CONTENTS


You can use the CONTENTS procedure in conjunction with an ODS OUTPUT statement to produce a data set of directory-level information. The sample code below produces a data set containing member type, file size, and last modified date for SAS files in the SASHELP library. Please note that specifying an actual data set name rather than using the keyword _ALL_ in the PROC CONTENTS example below generates an error.

ods select members;
ods output members=dataset(drop=level);

proc contents data=sashelp._all_;
run; 

ods output close;

proc print data=dataset;
run;


Similar information is provided by the DATASETS procedure.

ods output members=dsinfo;                  
proc datasets library=sashelp /* memtype=data */;  
quit;                                       
run;                                        
ods output close;  

Another way to produce a data set of directory-level information uses the SAS-supplied view called VMEMBER that resides in the SASHELP library. With this method, the member name, type, engine, dbms_memtype, index, and path information are available simply by querying the view. However, the size of the file is not included.

data members;
   set sashelp.vmember;
   where libname="SASHELP";
   /* Replace with your */
   /* library name, in upper case. */
run;