Hello.
I am using Stata 16. I have an unbalanced panel data set with firm (gvkey) observations over time (fiscal_quarter). I'm running the following regression

HTML Code:
reg DV x1 x2 x3 x4 c.x1#i.gvkey c.x1#i.fiscal_quarter c.x2#i.gvkey c.x2#i.fiscal_quarter c.x3#i.gvkey c.x3#i.fiscal_quarter c.x4#i.gvkey c.x4#i.fiscal_quarter, beta nocons
and would like to generate new variables (one assoicated with x1, x2, x3, x4) akin to

HTML Code:
gen x1total = _b[x1] + _b[c.x1#gvkey] + _b[c.x1#fiscal_quarter]
for x1. In other words, I would like to capture the coefficient for x1, which can be done with

HTML Code:
gen x1coeff = _b[x1]
and will be the same for each observation.

Next, I need to capture the coefficient for for the interaction of x1 with gvkey (my firm identifier), which will be the same for all observations within a firm but vary across firms, and capture the coefficient for the interaction of x1 with fiscal_quarter (my time variable), which will be the same for each time period across firms, but varies within firms.

I have searched extensively for a code on how to capture these coefficients to no prevail. I looked into using statsby, but it appears I would have to run the regression by groups (i.e., firms and then time periods), which is not what I want.

Any suggestions are greatly appreciated.
Best,
Annette