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 */
run;
proc glmselect data=workers noprint outdesign(addinputvars)=workers2;
class year;
model electric=year / noint selection=none;
run;
/*
proc print data=workers2;
run;
*/
proc autoreg data=workers2;
model electric = masonry year_1977-year_1981 / covest=hac(kernel=bartlett, bandwidth=7);
title 'With HAC correction';
run;
title;
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:
https://blogs.sas.com/content/iml/2020/08/31/best-generate-dummy-variables-sas.html
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:
https://support.sas.com/documentation/cdl/en/etsug/68148/HTML/default/viewer.htm#etsug_autoreg_detai...
https://support.sas.com/kb/40/098.html
I hope this helps!
DW