Hi,
Right now PROC PANEL only provides cluster s.e by id variable.
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.
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!
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.