Programming the statistical procedures from SAS

Ouput coefficients from GLS regression without ODS

Reply
Contributor
Posts: 21

Ouput coefficients from GLS regression without ODS

Hello everyone,

 

I would like to output the coefficients and their standard errors from a GLS regression, as well as the residuals and predicted values.

The following code does the job:

proc glm data=Work.Rwin;
	by grp;
	model Y1 = X1 X2 X3 X4 X5 X6 / noint;
	ods output ParameterEstimates=Work.Coeff1;  /* output coeff and their standard errors */
run;
quit;

proc glm data=Work.Rwin noprint;  
	by grp;
	model Y1 = X1 X2 X3 X4 X5 X6 / noint;
	output out=Work.Res1 p=predicted1 r=residus1; /* output residuals and predicted values */
run;
quit;

After searching on the forum and Internet, ODS is the only way I found to output the coefficients. The problem is that ODS requires to print, which is a an extremely long process given that I have thousands of rolling-windows regressions like this...

 

If you have any suggestion to improve this code and make it faster to process I would be very grateful. The best solution would be not to use ODS I think, and if it's not possible maybe to output everything with ODS instead of doing the regressions 2 times like this (with ODS first then with output out).

 

Thank you in advance for your help,

Frequent Contributor
Posts: 93

Re: Ouput coefficients from GLS regression without ODS

Perhaps ODS Exclude or %ODS off/on may assist:

 

http://blogs.sas.com/content/iml/2015/05/26/suppress-ods.html

 

Contributor
Posts: 21

Re: Ouput coefficients from GLS regression without ODS

I will look deeper into ODS EXCLUDE if it allows printing only coefficients and their standard errors, throwing away everything else. In this case it may be faster indeed, thank you.

SAS Super FREQ
Posts: 3,304

Re: Ouput coefficients from GLS regression without ODS

In your example, you have only main effects. There4fore you can use PROC REG instead of PROC GLM and use the OUTEST= option to write the parameter estimates. By the way, you can output all statistics in one call; no need to run the PROC twice:

 

proc reg data=Work.Rwin noprint outest=PE;
	by grp;
	model Y1 = X1 X2 X3 X4 X5 X6 / noint;
        output out=Res1 p=predicted1 r=residus1;
quit;

For a summary of other ways to output statistics in SAS, see "ODS OUTPUT: Store any statistic create by any SAS procedure."

 

Contributor
Posts: 21

Re: Ouput coefficients from GLS regression without ODS

[ Edited ]

When I started to write this program, I indeed outputted all the parameter estimates in one call:

 

proc reg data=Work.Rwin outest=Work.Coeff1 tableout noprint;
	by grp;
	model Y1 = X1 X2 X3 X4 X5 X6 / noint;
	output out=Work.Res1 p=predicted1 r=residus1;
run;
quit;

using "tableout" to get additional information, notably standard errors. But this is an OLS regression and I have substantial first-order autocorrelation in the error that I would like to adjust by estimating coefficients with the GLS method. That's why I use PROC GLM instead of PROC REG. Am I mistaken?

 

SAS Super FREQ
Posts: 3,304

Re: Ouput coefficients from GLS regression without ODS

I think you are mistaken. PROC GLM performs OLS for general linear models. It differs from PROC REG in that it supports a CLASS statement that internally generates dummy variables for categorical covariates.  It also supports ANOVA, MANOVA, and various hypothesis testing methods.

 

if you have autocorrelated data, you might want to look into the SAS/ETS procedures such as PROC AUTOREG, which provides Yule-Walker estimates.

Contributor
Posts: 21

Re: Ouput coefficients from GLS regression without ODS

Ah ok thank you, so I need to look how we perform GLS regressions with SAS (using GLS is a requirement in my case as I reproduce a procedure). Any hint?

Ask a Question
Discussion stats
  • 6 replies
  • 128 views
  • 2 likes
  • 3 in conversation