Hi,
I have gotten to the point where I'm running so many programs that it would take too much time to go through and document each run by hand. I'm looking to automate part or all of the process of documenting programs as (or after) I run them. Ideally, this is the information I would like (but if not all of it is possible, I will take what I can get):
-Date program was run
-Name and filepath of program
-Input files used by program
-Output files produced by program
-N of output files produced by program
Any help is much appreciated.
Take a look at SCAPROC though I suspect it's more than what you want. The good thing, it works exactly how you're suggesting, run the program in question and the 'documentation' appears after the run.
Unfortunately 'programming' your way out of bad design doesn't really work.
Scheduling your programs and run them automated would cover:
-Date program was run
-Name and filepath of program
If would also allow you to define dependencies between programs and dependencies to data sources plus you would also records things like completion codes of program execution.
First of all, wrap your programs in a batch/script file that assigns a unique timestamp to each run; use that timestamp in the log file name. Add code that records the run with its parameters before the actual job runs, and after that to add the result to that recording.
I could provide you code that does this.
Isn't that what the SAS log file does? You are saving your programs as .sas files and running them from the command line, right?
The other suggestions are great for capturing running of the program(s).Further to these suggestions you can store a timestamp before running the program and then at the end find all files newer than that timestamp to display/count the output.
For the input/output files an approach I've seen used in other languages is inline comments then generated into documentation. JavaDoc and Perl's POD are examples. SASUnit does this to produce documentation and reports. I believe they used to use DoxyGen however have switched to an internal tool. SASUnit can be found at http://sasunit.sourceforge.net/ but their report demo isn't working so download the 1.6 release and open this file for an example: example/doc/sasunit/en/rep/pgm_basedatasets.html.
Code:
/** \file \ingroup SASUNIT_EXAMPLES_PGM \brief Create base datasets for a database \version \$Revision: 451 $ \author \$Author: klandwich $ \date \$Date: 2015-09-07 08:49:43 +0200 (Mo, 07 Sep 2015) $ \sa For further information please refer to https://sourceforge.net/p/sasunit/wiki/User%27s%20Guide/ Here you can find the SASUnit documentation, release notes and license information. \sa \$HeadURL: https://svn.code.sf.net/p/sasunit/code/tags/v1.6/example/saspgm/basedatasets.sas $ \copyright This file is part of SASUnit, the Unit testing framework for SAS(R) programs. For copyright information and terms of usage under the GPL license see included file readme.txt or https://sourceforge.net/p/sasunit/wiki/readme/. */ /** \cond */
Report:
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.