Hmmm... so much ways of doing this.
Macro code will do this easily, mainly allowing you to create a loop that will process each row from the location dataset, fill some auxiliary macro variables, and extract the metadata.
But, macroless solutions are possible also.
Say for example, you could cycle through the location dataset and issue (through the execute routine) a sql dictionary tables/proc contents (I prefer the last) for each row, and concatenate the result to some dataset. Then you just have to proc export/ODS-proc print the result dataset to a CSV file.
* cycle and extract table metadata;
data _null_;
set file;
call execute('proc contents data = '''!! DATASETNAME !! ''''!!
' out = _CONTENTS noprint; run;'!!
'proc append base = CONTENTS data = _CONTENTS; run;');
run;
* output result to csv;
ods csv file= 'E:\Temp\CONTENTS.csv';
proc print data = CONTENTS noobs;
run;
ods trace on;
ods csv close;
Now, if you're going to run this piece of code more than one time on the same session, be sure to delete first the CONTENTS dataset.
Check the online documentation for the EXECUTE routine:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a000543697.htm
And read some more about the Output Delivery System here:
http://support.sas.com/documentation/cdl/en/odsug/61723/HTML/default/a002291014.htm
Cheers from Portugal.
Daniel Santos @ www.cgd.pt.
... View more