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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 1477 views
  • 1 like
  • 2 in conversation