Anda di halaman 1dari 2

Why did I create this macro?

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. 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. t 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;
support.sas.com > Samples

-- Navigate our Site --
Samples Home | Samples Published in SAS Documentation | Samples from SAS Developers
Sample 1184: Documenting the SAS run using SASheIp tabIes
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 T world having rumbled around various ndianapolis companies and operating
systems for the last 28 years doing T 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 nstitute nc. "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 nstitute shall not be liable for any damages whatsoever arising out of their use of this
material. n addition, SAS nstitute will provide no support for the materials contained herein.
Search | Contact Us | Terms of Use & Legal Information | Privacy Statement
Copyright 2005 SAS Institute Inc. All Rights Reserved.

Anda mungkin juga menyukai