I compare the results of a two-way fixed effects panel data regression returned by SAS and Stata and find the they are completely different.
Here below are my SAS code and result screen shot, where bHHIs is my variable of interest.
proc panel data=ASSD.province_quarter_2015_12;
id Province TimeID;
model LoanNum = bHHIs population GDP deltaFIL_GDP / fixtwo;
run;
Here below are screen shots of my stata settings and results, as currently I have not learned any codes of stata.
I choose Statistics -> Longitudinal/panel data -> Linear models -> Linear regression(FE, RE, PA, BE).
Regression settings:
Panel settings:
Automatically generated codes after submission:
And results:
As you can see, the coefficient of bHHIs flips the sign. Coefficients of other variables also change.
Note: in SAS I use "province_quarter_2015_12" whereas in Stata I use "province_quarter_2015_14". It's just because Stata does not accept string Panel ID so I change it into numbers.
Hello,
The two way fixed effects model parameter estimates can be replicated by running a regression with dummy variables on both cross sections and time periods. You can verify the results from PROC PANEL by specifying the two way fixed effects model using PROC MIXED or PROC GLM. An example is given at the end of this message. I do not have knowledge about STATA command to comment on whether you are specifying the same two way fixed effects model in STATA, but one thing you may want to check first is whether your STATA command is fitting a one way fixed effects model or a two way fixed effects model. In PROC PANEL, you can use PRINTFIXED option in the MODEL statement to print out the fixed effects estimates on the cross sections and time periods dummies. Two way fixed effects model should produce fixed effects estimates for both cross sections and time periods. If you can do the same in STATA and print out the fixed effects estimates as well, that may be helpful for you to verify your model specified in STATA, and how they compare with the fixed effects estimates in PROC PANEL.
In any case, the following is an example replicating two way fixed effects model estimates from PROC PANEL using PROC MIXED and PROC GLM.
data a ;
do cs = 1 to 5 ;
do ts = 1 to 15 ;
x = normal(1) ;
y = 2+3*x + 2*cs + 0.5*ts + rannor(32);
output;
end;
end;
run;
ods graphics off;
proc panel data =a ;
id cs ts;
model y = x /fixtwo printfixed ;
run;
proc mixed data = a ;
class cs ts ;
model y = x cs ts /solution;
run;
proc glm data = a ;
class cs ts ;
model y = x cs ts /solution;
run;
I hope this helps.
Hello,
I have moved your question to this "Econometrics" board.
Over here you have a better chance for an appropriate answer.
Calling for help by @SASCom1 .
Cheers,
Koen
Hello,
The two way fixed effects model parameter estimates can be replicated by running a regression with dummy variables on both cross sections and time periods. You can verify the results from PROC PANEL by specifying the two way fixed effects model using PROC MIXED or PROC GLM. An example is given at the end of this message. I do not have knowledge about STATA command to comment on whether you are specifying the same two way fixed effects model in STATA, but one thing you may want to check first is whether your STATA command is fitting a one way fixed effects model or a two way fixed effects model. In PROC PANEL, you can use PRINTFIXED option in the MODEL statement to print out the fixed effects estimates on the cross sections and time periods dummies. Two way fixed effects model should produce fixed effects estimates for both cross sections and time periods. If you can do the same in STATA and print out the fixed effects estimates as well, that may be helpful for you to verify your model specified in STATA, and how they compare with the fixed effects estimates in PROC PANEL.
In any case, the following is an example replicating two way fixed effects model estimates from PROC PANEL using PROC MIXED and PROC GLM.
data a ;
do cs = 1 to 5 ;
do ts = 1 to 15 ;
x = normal(1) ;
y = 2+3*x + 2*cs + 0.5*ts + rannor(32);
output;
end;
end;
run;
ods graphics off;
proc panel data =a ;
id cs ts;
model y = x /fixtwo printfixed ;
run;
proc mixed data = a ;
class cs ts ;
model y = x cs ts /solution;
run;
proc glm data = a ;
class cs ts ;
model y = x cs ts /solution;
run;
I hope this helps.
Thanks for the solution.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.