Sample 25628: Documenting the SAS run using SAShelp tables
Why did I create this macro? I write a lot of macros that input and output files based on parameters given to the high order program and as a result, the list of external files and SAS datasets that go in and out of a run can be flexible based on other parameters controlling the logic flow. I discovered a simple method using another macro that accesses the SAShelp tables to add to the bottom of the SAS run deck which gives me the full path names of the files input and output from the run on the list dataset. Using good fileref names delineates the inputs from the outputs. It sure beats digging through the log to find this information or worse yet, trying to create separate documentation to match what the program did, then needing to verify you typed everything correctly to match what actually happened.
So here is the macro code. Try it, and see if you can eliminate some documentation requirements for yourself!
Note:
Add the following code to the bottom of your SAS program (before the ENDSAS, please)!
FILENAME _ALL_ LIST;
%macro fields;
/* List External files used in this run */
proc sql;
create view file as
select fileref, xpath
from SASHELP.vextfl;
quit;
data files;
set file;
if fileref =: '#LN' or fileref =: 'SAS' then delete;
run;
proc print;
title "External non sas files used in this run";
run;
/* List external sas files used or created */
proc sql;
create view path as
select libname,memname,path
from dictionary.members;
quit;
data paths;
set path;
if libname = 'SASHELP' or
libname = 'MAPS' or
libname = 'WORK' or
libname = 'SASUSER' then delete;
run;
proc sort data=paths;
by libname memname;
run;
proc print;
title "SAS Files used this run and their attributes" ;
run;
%mend fields;
%fields;

About the Author
David Cross is one of those old guys in the IT world having rumbled around various Indianapolis companies and operating systems for the last 28 years doing IT work. He really believes in the saying: "There has got to be an easier way to do this." David currently works for Eli Lilly as an Associate Senior Pharmacokineticist.
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.