SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

SAS programs to automatically document programs/datafiles

Reply
Frequent Contributor
Posts: 138

SAS programs to automatically document programs/datafiles

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.

Super User
Posts: 17,819

Re: SAS programs to automatically document programs/datafiles

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. 

Respected Advisor
Posts: 3,890

Re: SAS programs to automatically document programs/datafiles

@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.

Super User
Posts: 6,936

Re: SAS programs to automatically document programs/datafiles

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 6,500

Re: SAS programs to automatically document programs/datafiles

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?

Occasional Contributor
Posts: 5

Re: SAS programs to automatically document programs/datafiles

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:

 

Ask a Question
Discussion stats
  • 5 replies
  • 146 views
  • 0 likes
  • 6 in conversation