BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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!
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
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 DICTIONARY.xxx files or their equivalent SASHELP.yyy files. For more information, look at some of these resources:
http://support.sas.com/documentation/cdl/en/sqlproc/59727/HTML/default/a001385596.htm
http://www2.sas.com/proceedings/sugi28/118-28.pdf
http://www2.sas.com/proceedings/forum2007/235-2007.pdf
http://www2.sas.com/proceedings/sugi29/237-29.pdf
http://support.sas.com/kb/25/436.html
http://www2.sas.com/proceedings/forum2007/103-2007.pdf

cynthia
GertNissen
Barite | Level 11
Hi GP

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)
[pre]
Filename dirlist pipe 'dir p:\*.sas /B';
data fnames(keep=filename);
infile dirlist pad missover;
input @1 filename $62.;
run;

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

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

See the following papers for ideas
http://www2.sas.com/proceedings/sugi25/25/cc/25p074.pdf
http://www2.sas.com/proceedings/sugi27/p208-27.pdf
http://www2.sas.com/proceedings/sugi29/258-29.pdf
GertNissen
Barite | Level 11
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 Webhttp://www2.sas.com/proceedings/forum2008/232-2008.pdf

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1195 views
  • 0 likes
  • 3 in conversation