Help using Base SAS procedures

Getting p values out of proc autoreg

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 133
Accepted Solution

Getting p values out of proc autoreg

Hello all-

So I have the fake sample set below with dates and then values for Field A and B.

A is clearly declining over time, B is not.

I know how to export out the values such as trendhat so that I can actually produce a graph in ODS later.

However, how can I actually export out the p value in this case (for month) to demonstrate that in this case, the "trend" is or is not actually statistically significant for time.

I want to take this p value and then translate it into a legend into a graph. Everything else I know how to do.

Many Thanks

Lawrence

ps Sorry for the crude input for time. I really forgot how to manually enter data into a dataset.

DATA X;

INPUT @2 MONTH_CHAR $ A B;

MONTH=input(MONTH_CHAR,mmddyy10.);

DATALINES;

'01/01/12' 26 26

'02/01/12' 24 12

'03/01/12' 23 26

'04/01/12' 20 17

'05/01/12' 21 25

'06/01/12' 18 19

'07/01/12' 16 28

'08/01/12' 14 20

'09/01/12' 13 18

'10/01/12' 10 20

'11/01/12' 11 14

'12/01/12' 8 8

'01/01/13' 6 20

'02/01/13' 4 22

'03/01/13' 3 6

'04/01/13' 2 25

'05/01/13' 6 28

'06/01/13' 1 22

;

proc autoreg data=X ;

model A=month /nlag=2 method=ml;

output out=X_A  pm=trendhat ;run;

proc autoreg data=X ;

model B=month /nlag=2 method=ml;

output out=X_B  pm=trendhat ;run;


Accepted Solutions
Solution
‎11-14-2013 12:20 PM
Frequent Contributor
Frequent Contributor
Posts: 133

Re: Getting p values out of proc autoreg

Reeza;

Very helpful-

So the table I want is

ParameterEstimatesGivenAR

But when I try to set the parameter ods table mytablename=ParameterEstimatesGivenAR-

It returns an error.

When I just use ods table ParameterEstimatesGivenAR  it works finr but I cannot seem to define the table name.

Thanks again.

Lawrence

View solution in original post


All Replies
Grand Advisor
Posts: 16,933

Re: Getting p values out of proc autoreg

Use ODS Trace to determine the table (Check the log) and then use ods table mytablename=ptable before proc to store table.

ods trace on;

ods table tablename=my_Table;

proc autoreg data=X ;

model A=month /nlag=2 method=ml;

output out=X_A  pm=trendhat ;run;

ods trace off;

proc print data=my_table;

run;

Solution
‎11-14-2013 12:20 PM
Frequent Contributor
Frequent Contributor
Posts: 133

Re: Getting p values out of proc autoreg

Reeza;

Very helpful-

So the table I want is

ParameterEstimatesGivenAR

But when I try to set the parameter ods table mytablename=ParameterEstimatesGivenAR-

It returns an error.

When I just use ods table ParameterEstimatesGivenAR  it works finr but I cannot seem to define the table name.

Thanks again.

Lawrence

Grand Advisor
Posts: 16,933

Re: Getting p values out of proc autoreg

You did it backwards:

ods table ParameterEstimatesGivenAR=Mytablename;

Frequent Contributor
Frequent Contributor
Posts: 133

Re: Getting p values out of proc autoreg

Reeza;

Gotcha! Not enough coffee yet in the system!

Many Thanks this is great!

Lawrence

Frequent Contributor
Frequent Contributor
Posts: 133

Re: Getting p values out of proc autoreg

Reeza;

OK One more question-

In order to use this I need to leave the print option on-This causes all the parameters to be output into my report which I don't want-

I attempted to redirect the log to bypass this but that does not work..Is there a way to have my cake and eat it too

(i.e. get the parameters table but suppress the output from the proc autoreg)

Thanks

Lawrence

Grand Advisor
Posts: 16,933

Re: Getting p values out of proc autoreg

Turn of ods listings or whatever your destination is?

ODS Listing Close;

ODS LISTING;

or ODS SELECT NONE before the proc? I think that still allows you to capture the table, but not 100% sure.

ODS SELECT ALL after the proc to reset.

Frequent Contributor
Frequent Contributor
Posts: 133

Re: Getting p values out of proc autoreg

I will try that. Thanks.

Lawrence

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 350 views
  • 0 likes
  • 2 in conversation