Dear Statalist,

I am working on a panel dataset (xtset firm year).

I want to divide the firms into two subgroups. One for small firms and the second for bigger firms.
The category a firm belongs to should be determined by the mean of its assets over time.
This is also an unbalanced panel so that for some firms, the mean must be based on two years, while it can be based on eight years for other firms.
Then, firms with mean(ASSETS) above median should be categorized as "big_firms" (dummy=1), while small firms get dummy=0.

I hope you can help me with this.