Hi,
I'm trying to export multiple regression outputs to .tex and creating a stack of multiple panels, as shown in https://medium.com/@linglp/nice-regr...a-17d3895befd2
I'm following the exact same code as in the blog:
The code works fine till panel 3, at which point while trying to export the output to "$out\table.tex", I get an error
I'm not quite sure why this is happening, as I append the results in panel 3 to the earlier results. Moreover, the panel 2 results are also appended in same way to panel 1 results but it doesn't get flagged as error then.
Any help would be appreciated, thanks!
I'm trying to export multiple regression outputs to .tex and creating a stack of multiple panels, as shown in https://medium.com/@linglp/nice-regr...a-17d3895befd2
I'm following the exact same code as in the blog:
Code:
use "$data\data.dta",clear
/*panel 1*/
eststo clear
foreach var of varlist y1 y2 y3{
eststo: areg `var' i.treat##i.after x1 x2 x3, absorb(x4) cluster(cluster)
estadd local fe1 "Yes"
estadd local fe2 "Yes"
estadd local control "Yes"
}
esttab est1 est2 est3 using "$out\table.tex", ///
drop (x1 x2 x3) ///
prehead ("\begin{table}[htbp]\centering \\ \def\sym#1{\ifmode^{#1}\else\(^{#1}\)\fi} \\ \caption{title} \\ \begin{tabular}{l*{3}{c}} \hline\hline") ///
posthead ("\hline \\ \multicolumn{3}{c}{\textbf{Panel A}} \\\\[-1ex]") ///
fragment ///
mtitles ("y1" "y2" "y3") stats (r2 N fe1 fe2 control, labels(R-squared "observations" "FE1" "FE2" "Control variables")) b(%8.3f) se(%8.3f)
/*replace*/
eststo clear
/*panel 2*/
eststo clear
foreach var of varlist y1 y2 y3{
eststo: areg `var' i.treat2##i.after x1 x2 x3, absorb(x4) cluster(cluster)
estadd local fe1 "Yes"
estadd local fe2 "Yes"
estadd local control "Yes"
}
esttab est1 est2 est3 using "$out\table.tex" ///
drop (x1 x2 x3) ///
posthead("\hline \\ \multicolumn{3}{c}{\textbf{Panel B}} \\\\[-1ex]") ///
fragment ///
append ///
r2 b(%8.3f) se(%8.3f) stats(r2 N fe1 fe2 control, labels(R-squared "observations" "FE1" "FE2" "Control variables")) nomtitle nonumbers
/*panel 3*/
eststo clear
foreach var of varlist y1 y2 y3{
eststo: areg `var' i.treat3##i.after x1 x2 x3, absorb(x4) cluster(cluster)
estadd local fe1 "Yes"
estadd local fe2 "Yes"
estadd local control "Yes"
}
esttab est1 est2 est3 using "$out\table.tex" ///
drop (x1 x2 x3)
posthead("\hline \\ \multicolumn{3}{c}{\textbf{Panel C: title}} \\\\[-1ex]") ///
fragment ///
append ///
r2 b(%8.3f) se(%8.3f) stats(r2 N fe1 fe2 control, labels(R-squared "observations" "FE1" "FE2" "Control variables")) nomtitle nonumbers ///
prefoot ("\hline") ///
postfoot ("\hline\hline \multicolumn{6}{l}{\footnotesize Standard errors in parentheses}\\\multicolumn{2}{l}{footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***}\(p<0.001\)}\\ \end{tabular}\\ \end{table}")
Code:
file C:\Users\....\table.tex already exists r(602);
Any help would be appreciated, thanks!

Comment