tags:

views:

197

answers:

3

In SAS, How do I add comments to my .LST output file. Like adding a comment saying "This is the output for tbl_TestMacro:" right before doing a proc print? So that my output file will read:

This is the output for tbl_TestMacro:
Obs    field1    field2

 1        6         8  
 2        6         9  
 3        7         0  
 4        7         1  

Instead of just:

Obs    field1    field2

 1        6         8  
 2        6         9  
 3        7         0  
 4        7         1  

Thanks, Dan

+5  A: 

You may actually have more luck on stackoverflow for numerical computing language questions (such as SAS and R).

But I'll try my hand at it anyway. Both TITLE and PUT would work for your purposes:

title "This is the output for tbl_TestMacro:";

or

put This is the output for tbl_TestMacro:;
Tyler
Title is my recommendation. Just remember the title will show up on all listing output until you blank it out or overwrite it.
CTKeane
and "put" will put the text in the log, unless you have directed it to do otherwise-- see Ken's answer and my answer below.
Louisa Grey
+1  A: 

I believe that "put" will put the answer in the log, not the listing.

The title will work, but it only puts the title at the top of the page.

There's no elegant way within SAS to combine textual comments with output. The best tools I'm aware of for this are SASweave and StatWeave, both developed by Russ Lenth. They might require more investment of time than you're willing to give. Or, you could use R and Sweave.

An ugly way to do this, however, is to make a data set with the text you want, and to use a routine such as the following:

data mytext; text = "This is the output for tbl_TestMacro"; run;

proc print noobs data = mytext split=''; var text; label text = ''; run;

(There's meant to be a better shortcut for no variable label, but I failed to make it work.)

+1  A: 

Or you could do

data _null_;
    file print;
    put "this is the output";
    file log;
run;

See http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000171874.htm for more information about changing the destination of "put."

Louisa Grey