Saving coefficients


I have a panel dataset and I need to run individual regressions by "i", so I did:

by i: reg y x

Then I need to have a colum with the coefficients of each regression results.

that is for each "i" I will have coefficient that are constant overtime.

I tried to gen a matrix:

matrix A = e(b)

but it doesn't work.

What can I do?

Hey there,

If you want to store the coefficients in a matrix Ai, use the 'for' command:

levelsof i, local(indiv)
foreach i of local indiv {
reg y x if i == `i'
matrix A`i' = e(b)

Hope this helps