DATA Step, Macro, Functions and more

How do I make Automated Documentation

Posts: 0

How do I make Automated Documentation

Not sure whether I'm at right spot, I wanted to know if I can make documentation of SAS codes automated. I heard it can be done using Macros. Please suggest on this.

Also, if this isn't the right place to ask questions like this, please let me know.. Thanks!
Posts: 8,743

Re: How do I make Automated Documentation

I'm not sure what you mean by "SAS codes" -- do you mean the SAS programs themselves, the SAS logs?? Or producing information about the dataset size, number of obs, variable names, labels, formats, etc?

With or without a SAS macro program, you can easily get dataset and variable information from the various files or their equivalent SASHELP.yyy files. For more information, look at some of these resources:

SAS Employee
Posts: 160

Re: How do I make Automated Documentation


What do you want documented from your SAS code ?

If you want to document your input and output data, its not that simple - because you will have to build your own parser because of the many many ways sas data can be referenced in the SAS code (i.e. datasets, proc's etc and macro var. ref.).

If you want to have basic metadata about your program, like who developed it, when, description, status etc. you can do this by using a standard header in all your programs (at the top). You will need to infile all your sas files in a datastep, and read your header information into a SAS dataset.

Its not necessary to write a macro, a normal SAS program can do the job just fine.

i.e try this mock-up (has to be refined before use - not tested)
Filename dirlist pipe 'dir p:\*.sas /B';
data fnames(keep=filename);
infile dirlist pad missover;
input @1 filename $62.;

data sascode;
retain file;
length string $120;
set fnames(keep=filename obs=10);
infile dummy filevar=filename end=done dsd;
do while(not done);
input string :$120.;

You will have to do some IF testing using substr(), index() etc. when reading your standard header.

See the following papers for ideas
SAS Employee
Posts: 160

Re: How do I make Automated Documentation

Well - the latest issue of the "SAS® Tech Report - november 2008" has this hint.....

Great Forum Paper Series, Continued: Publishing SAS® Code Documentation »
This paper introduces DocItOut - a free, open source tool specifically developed to traverse messy directories and generate properly formatted Web documentation in HTML format, based on the comments and statements in the SAS code.
DocItOut: Publishing SAS® Code Documentation on the Web
Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation