Hello everyone,
I hope you are all doing well.
Kindly, I need your help on the following (I found a similar post, but I couldn't customise the code posted to my data):
I have a panel data ranging between 1990 till 2015. I need to loop regressions by year and industry and store the estimates in separate variables. The regression equation is Y = X1 + X2 + X3 + e.
I am trying the following:
Unfortunately, Stata is returning an error message: no variables defined
Thank you for your suggestions.
Mostafa
I hope you are all doing well.
Kindly, I need your help on the following (I found a similar post, but I couldn't customise the code posted to my data):
I have a panel data ranging between 1990 till 2015. I need to loop regressions by year and industry and store the estimates in separate variables. The regression equation is Y = X1 + X2 + X3 + e.
I am trying the following:
Code:
gen B1=. gen B2=. gen B3=. levelsof INDUSTRY, local(levels) foreach x of local levels { foreach z of numlist 1990/2015 { capture reg Y X1 X2 X3 if INDUSTRY==`x' & YEAR==`z' if e(N) >= 10 { replace B1=_b[X1] if e(sample) replace B1=_b[X2] if e(sample) replace B1=_b[X3] if e(sample) } } }
Thank you for your suggestions.
Mostafa
Comment