I am hoping that someone has advice on how to append tables created with esttab for Latex. The code that I have right now can be used to create two separate tables one with the descriptive stats and one with the number of observations. What I would like to do is append these two tables (see below) so that the number of observations is included as the bottom row of the descriptive stats table (and the number of observations only shows up once).

This is the code I am using (when I add the fragment option the file will not compile in Latex):
/// set the variables
global variables elecyear2_dum elecyear2 incometot inc_cattle inc_crops incoff inc_gov durables_elec origin_south yearmove good_soil distopo settime
/// number of observations set equal to treatment.
gen num_obs=elecyear2_dum
label var num_obs "Obs."
/// begin table 1: des stats for treatment, outcomes, controls
est clear
estpost tabstat $variables, by(year) c(stat) stat(mean sd) nototal
esttab using "$tables/t_descstats_general.tex", replace ///
cells(mean(fmt(2)) sd(par)) nostar nonumber unstack ///
nomtitle nonote noobs label booktabs ///
refcat(elecyear2_dum "\emph{Treatment}" incometot " \emph{Outcomes}" origin_south " \emph{Controls}", nolabel) ///
eqlabels("1996" "2000" "2005" "2009") title(Descriptive Statistics\label{t-descstats-general})
bysort year: eststo: qui estpost summarize num_obs, listwise
/// begin table 2: number of observations by year
esttab using "$tables/t_descstats_general2.tex", replace cells("count") nodepvar label nonum collab(none) nonumber nomtitle noobs booktabs title(Descriptive Statistics2\label{t-descstats-general2})
And finally, a sample of the data is here:
year yearmove incoff distopo incometot durables_elec good_soil elecyear2 elecyear2_dum origin_south inc_gov inc_crops inc_cattle settime
1996 1991 0 42.55465 4284.35 2 1 1992 1 0 0 4284.35 0 1970
2000 1990 5976 42.55465 11266.71 0 1 1992 1 1 1812 140 1526.715 1970
2005 2001 1891.018 39.86766 3536.414 0 0 2008 0 1 419.9328 805.53 0 1970
1996 1994 0 27.8091 1427.728 0 0 1994 1 1 0 1251.35 176.3782 1970
2000 1990 0 27.8091 4551.696 2 0 1994 1 1 0 0 4551.696 1970
2005 2004 0 27.8091 11769.94 6 0 1994 1 1 0 0 5167.221 1970
2009 2003 0 27.8091 34497.43 9 0 1994 1 1 0 0 34497.43 1970
1996 1993 0 50.87988 42813.14 0 0 1998 0 1 0 37169.04 5644.103 1970
2000 1981 0 50.87988 6532.028 13 0 1998 1 0 3624 0 2908.028 1970
2005 1981 0 50.87988 16951.16 2 0 1998 1 0 4252.15 0 8374.227 1970
2009 1981 0 50.87988 15918.97 6 0 1998 1 0 6165.746 0 2758.751 1970
Thanks for any help.
This is the code I am using (when I add the fragment option the file will not compile in Latex):
/// set the variables
global variables elecyear2_dum elecyear2 incometot inc_cattle inc_crops incoff inc_gov durables_elec origin_south yearmove good_soil distopo settime
/// number of observations set equal to treatment.
gen num_obs=elecyear2_dum
label var num_obs "Obs."
/// begin table 1: des stats for treatment, outcomes, controls
est clear
estpost tabstat $variables, by(year) c(stat) stat(mean sd) nototal
esttab using "$tables/t_descstats_general.tex", replace ///
cells(mean(fmt(2)) sd(par)) nostar nonumber unstack ///
nomtitle nonote noobs label booktabs ///
refcat(elecyear2_dum "\emph{Treatment}" incometot " \emph{Outcomes}" origin_south " \emph{Controls}", nolabel) ///
eqlabels("1996" "2000" "2005" "2009") title(Descriptive Statistics\label{t-descstats-general})
bysort year: eststo: qui estpost summarize num_obs, listwise
/// begin table 2: number of observations by year
esttab using "$tables/t_descstats_general2.tex", replace cells("count") nodepvar label nonum collab(none) nonumber nomtitle noobs booktabs title(Descriptive Statistics2\label{t-descstats-general2})
And finally, a sample of the data is here:
year yearmove incoff distopo incometot durables_elec good_soil elecyear2 elecyear2_dum origin_south inc_gov inc_crops inc_cattle settime
1996 1991 0 42.55465 4284.35 2 1 1992 1 0 0 4284.35 0 1970
2000 1990 5976 42.55465 11266.71 0 1 1992 1 1 1812 140 1526.715 1970
2005 2001 1891.018 39.86766 3536.414 0 0 2008 0 1 419.9328 805.53 0 1970
1996 1994 0 27.8091 1427.728 0 0 1994 1 1 0 1251.35 176.3782 1970
2000 1990 0 27.8091 4551.696 2 0 1994 1 1 0 0 4551.696 1970
2005 2004 0 27.8091 11769.94 6 0 1994 1 1 0 0 5167.221 1970
2009 2003 0 27.8091 34497.43 9 0 1994 1 1 0 0 34497.43 1970
1996 1993 0 50.87988 42813.14 0 0 1998 0 1 0 37169.04 5644.103 1970
2000 1981 0 50.87988 6532.028 13 0 1998 1 0 3624 0 2908.028 1970
2005 1981 0 50.87988 16951.16 2 0 1998 1 0 4252.15 0 8374.227 1970
2009 1981 0 50.87988 15918.97 6 0 1998 1 0 6165.746 0 2758.751 1970
Thanks for any help.
Comment