Dan
Dan

Reputation: 10171

SAS: add comment to lst ouput file

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

Upvotes: 4

Views: 6639

Answers (3)

Ken
Ken

Reputation:

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

Upvotes: 2

Lauren Samuels
Lauren Samuels

Reputation: 2529

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

Upvotes: 4

Tyler
Tyler

Reputation: 626

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:;

Upvotes: 7

Related Questions