BookmarkSubscribeRSS Feed
Walternate
Obsidian | Level 7

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.

5 REPLIES 5
Reeza
Super User

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. 

Patrick
Opal | Level 21

@Walternate

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.

Kurt_Bremser
Super User

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.

Tom
Super User Tom
Super User

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?

hamish_at_nab
Fluorite | Level 6

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:

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 5 replies
  • 1144 views
  • 0 likes
  • 6 in conversation