BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Alain38
Quartz | Level 8

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,

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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.

View solution in original post

5 REPLIES 5
Alain38
Quartz | Level 8

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.

Rick_SAS
SAS Super FREQ

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

 

Alain38
Quartz | Level 8

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?

 

Rick_SAS
SAS Super FREQ

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1831 views
  • 2 likes
  • 3 in conversation