BookmarkSubscribeRSS Feed
SayeE
Calcite | Level 5
I have the following code for my two-way fixed effect model. In my dataset "data1", there are a few "units" in each "firm". How I can get the heteroskadasticity-robust standard errors clustered by  "firm". 
 
proc sort data=data1;
by  unit time;
run;
proc panel data=data1;
      id unit time;
      model DV = x  /FIXTWO;  
   run;

 
2 REPLIES 2
xyz0505
SAS Employee

Hi,

Right now PROC PANEL only provides cluster s.e by id variable.

xyz0505
SAS Employee

There's a trick you can use to cluster on variable that is not ID using proc panel. If you have an ID variable (maybe firm), time variable, and an ID2 variable you want to cluster on (let's say industry, for example).

 

First sort the data according to id2 variable, and create a new variable called time2. time2 variable give sequence for each observation in each id2 group. Example looks like:

id t id2 t2
1 1 1 1
1 2 1 2
1 3 1 3
1 4 1 4
1 5 1 5
1 6 1 6
2 1 1 7
2 2 1 8
2 3 1 9
2 4 1 10
2 5 1 11
2 6 1 12
3 1 2 1
3 2 2 2
3 3 2 3
3 4 2 4
3 5 2 5
3 6 2 6
4 1 2 7
4 2 2 8
4 3 2 9
4 4 2 10
4 5 2 11
4 6 2 12

 

Then sort the data according to id2 and time2.

Then run:

proc panel data = panel_example3 ;
     Id id2 t2;
     class id;
     model y = x1 x2 id / pooled hccme=0 cluster;
run;

 

should give you fixone model with fixed effects on id but clustering on id2.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Discussion stats
  • 2 replies
  • 2049 views
  • 1 like
  • 2 in conversation