I use class
in proc glm
to run a one-way fixed-effect model as follows.
data have;
do i=1 to 3;
do j=1 to 3;
do k=1 to 10;
x=rannor(1);
y=x+rannor(1);
output;
end;
end;
end;
run;
proc glm data=have;
class i;
model y=x i/noint solution;
ods output parameterestimates=oneway_class;
quit;
Or sometimes I use absorb
because it is faster than class
.
proc glm data=have;
absorb i;
model y=x/noint solution;
ods output parameterestimates=oneway_absorb;
quit;
And I found that absorb
, unlike class
, cannot estimate a two-way fixed-effect model in this way.
/*THE FOLLOWING ESTIMATES TWO-WAY FIXED-EFFECT MODELS CORRECTLY*/
proc glm data=have;
class i j;
model y=x i j/noint solution;
ods output parameterestimates=twoway_class;
quit;
/*THE FOLLOWING DOES NOT ESTIMATE TWO-WAY FIXED-EFFECT MODELS*/
proc glm data=have;
absorb i j;
model y=x/noint solution;
ods output parameterestimates=twoway_absorb;
quit;
Though the first glm
with class
is correct, it becomes too slow because the real data have so many observations. How can I estimate a two-way fixed-effect model with absorb
in glm
instead?
Correct.
If you use the ABSORB statement with two variables, ABSORB assumes that the second variable in the list is nested within the first, and this is not the design you have.
Correct.
If you use the ABSORB statement with two variables, ABSORB assumes that the second variable in the list is nested within the first, and this is not the design you have.
Thanks. Then should I give up the absorb
approach for two-way fixed effects?
@Junyong wrote:
Thanks. Then should I give up the
absorb
approach for two-way fixed effects?
I would replace the word "should" with "must"
Sad news since LSDV-estimating multi-way fixed-effect models is computationally costly, but thanks anyway.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.