Hi,
I am trying to extract and report the coefficient on "x_sd" at the bottom of the regression table as a local. I would like to display it the same way I do for the mean of the dependent variable, R2 and number of observations (please see the code below). However, Stata sends an error message "0.1458 invalid name". In the error message, 0.1458 is the coefficient on "x_sd" from the regression
.
Please find below the entire code I am running.
How can I effectively save the coefficient on and report it in the table in a similar way as the number of observations (and the mean of the dependent variable, as well as R2)?
I am trying to extract and report the coefficient on "x_sd" at the bottom of the regression table as a local. I would like to display it the same way I do for the mean of the dependent variable, R2 and number of observations (please see the code below). However, Stata sends an error message "0.1458 invalid name". In the error message, 0.1458 is the coefficient on "x_sd" from the regression
Code:
reg y x_sd i.year i.state, robust
Please find below the entire code I am running.
How can I effectively save the coefficient on and report it in the table in a similar way as the number of observations (and the mean of the dependent variable, as well as R2)?
Code:
eststo clear
** col1
reg y x i.year, robust
estadd local yearfe "Yes"
estadd local statefe "No"
est store COL1
sum y
estadd scalar meany `r(mean)'
** col2
reg y x i.year i.state, robust
estadd local yearfe "Yes"
estadd local statefe "Yes"
est store COL1
** sd estimate
sum x, de
gen x_sd= (x-`r(mean)')/`r(sd)'
reg y x_sd i.year i.state, robust
local sd = _b[x_sd]
*Print table - main text
esttab COL1 COL2 using "table.tex" , ///
replace noobs b(%10.3f) se star(* 0.10 ** 0.05 *** 0.01) ///
scalars("yearfe Year Fixed Effects" "statefe State Fixed effects" "r2 R^2" "N Observations" "meany Dep. var Mean" "`sd' SD") ///
sfmt(%9.0fc %9.0fc %9.0fc %9.2fc %9.0fc %9.2fc) align(cc) mtitles ("Col1" "Col2") label nogaps numbers nonotes keep(x)
