Sunday, September 23, 2007

how can we output the SAS estimated parameters?

1)
For each SAS procedure, SAS produces a group of ODS output objects. In order to know what objects are associated with a particular proc, we use ods trace on statement right before the proc and turn the trace off right after it.

ods trace on /listing;
proc reg data=****;
model *****;
run;
quit;
ods trace off;
2) After knowing the label of object, we can

use the label to create a data set just as using
the name. Eg, one label of the Reg Output is
"Parameter Estimates", now we can try:
ods output "Parameter Estimates"=parest;
proc reg data=***;
model ****;
run;
quit;
ods output close;


Trick:

A)
We can NOT use noprint option since ODS requires an output object.but the statement
ods listing close;
eliminates the output to appear in the output window. After the proc reg, we turn
back the listing output back so output will appear in the output window again.

ods listing close;
ods output "Parameter Estimates"=****;
proc reg data=****;
model ****;
run;
quit;
ods output close;
ods listing;

B)Output to an HTML file

Let's say that we want to write the output of our proc reg to an HTML file. This can be done very easily using ODS. First we specify the file name we are going to use. Then we point the ods html output to it. At the end we close the ods html output to finish writing to the HTML file. You can view procreg.html created by the following code.

filename myhtml "c:\examples\procreg.html";
ods html body=myhtml;
proc reg data=hsb25;
model write= female math;
run; quit;
ods html close;

No comments: