BookmarkSubscribeRSS Feed
Calcite | Level 5

Hi, I would like to know how to add time fixed effect as well as newey west t stat together when dealing with time series data regression. To be specified, I now have a 10-year daily data which is autocorrelated as y variable, and several time series x variables. I want to add year dummies (as fixed effects) and also use newey west t stat (or other t stat that adjusts for autocorrelation). I know "proc model " can deal with newey west t stat, but it cannot add time fixed effects neatly as "proc glm" by using "class" or "absorb" statement, and now I can only add year dummies mannually, which is not feasible when dealing with hundreds or thousands levels of fixed effect.

I wonder:

(1) is there any way to add year fixed effect dummies conviniently using proc model?

(2) if not, is there any other statement rather than "proc model" that support a autocorrelated adjusted t stat (eg. newey west t stat) as well as neat time fixed effect?


Jade | Level 19

Moved to Forecasting and Econometrics, in hope of attracting answers from those familiar with SAS/ETS.



SAS Employee

Hi @ZhaoJin , 


Assuming your data is strictly time series (rather than panel data), one approach that provides the most flexibility is to use PROC GLMSELECT to define the year dummy variables and then use PROC AUTOREG to fit the regression model with the fixed-effect dummies and the Newey-West correction.  Following, please find an example to illustrate:

data workers;
  set sashelp.workers;
  year=year(date);  /* create YEAR variable from SAS date variable */

proc glmselect data=workers noprint outdesign(addinputvars)=workers2;
  class year;
  model electric=year / noint selection=none;

proc print data=workers2;

proc autoreg data=workers2;
  model electric = masonry year_1977-year_1981 / covest=hac(kernel=bartlett, bandwidth=7);
  title 'With HAC correction';

The above model omits the dummy variable associated with the last level of YEAR (year_1982).


For more details on using PROC GLMSELECT to create dummy variables, please see the following blog posting by Rick Wicklin: 


For more details on the Heteroscedasticity and Autocorrelation-consistent covariance matrix estimators supported in PROC AUTOREG, including Newey-West, please see the documentation and SAS Note links below: 


I hope this helps!




Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1 like
  • 3 in conversation