Question

I'm trying to write a program in SAS that supports decision-making process in selecting the best formula of linear regression model. I even had one but in R environment. Now I have to implement it in SAS. The final result should be a dataset with each line decribing different regression formulas i.e. names of explanatory variables, R-squared, p-values for different statistical tests, etc.

As an example, one of the tests is Durbin-Watson test for autocorrelation. My goal is to insert a p-value into the table I've mentioned. I use the code:

proc reg data=indata outest=outdata EDF ridge=0 OUTVIF;
   model PKB = PK INV SI / DW;
run;
quit;

And as a result I get in the output window:

Durbin-Watson Statistics
Order            DW    Pr < DW    Pr > DW
    1          1.2512     0.0038     0.9962

I want to insert those p-values directly into the SAS table. I tried to find an answer in the SAS OnlineDoc and on the forum but with no success.

Était-ce utile?

La solution

ODS OUTPUT is the best way to get information that you can print to the screen into datasets. Use ODS TRACE ON; before your code, run it, then inspect the log; see what table name matches what you're looking for. Then use ODS OUTPUT <tablename>=<datasetname>.

For example, in this PROC FREQ, I see ONEWAYFREQS is the table I want.

ods trace on;
proc freq data=sashelp.class;
var age;
run;
ods trace off;

So I use ODS OUTPUT:

ods output onewayfreqs=ages;
proc freq data=sashelp.class;
table age;
run;
ods output close;

and get a nice dataset. (ODS TRACE is not necessary if you know the name of the table you're looking for.)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top