Dear statalisters,
I have a dataset (described by dataex at the end of this post) for which I would like to output a nice table that displays means and standard errors for specific sub-samples.
In order to make these tables I'm using a guide on how to use estout written by Ben Jann. Estout is package installable through SSC to output tables in Word-format.
That guide provides this example code as the correct way to achieve what I want:
I've modified this code to my needs:
The output of the tabstat command itself looks like what I want to achieve (except in a nicer format of course).
Using the command:
I also verified that there are actually things stored in the memory. This is the output of that command:

It only displays the number of observations in the dataset, while I want it to display the mean and standard errors of EEC_1 to EEC_5 by category. Does anyone know what I'm doing wrong?
This is what my data looks like:
I have a dataset (described by dataex at the end of this post) for which I would like to output a nice table that displays means and standard errors for specific sub-samples.
In order to make these tables I'm using a guide on how to use estout written by Ben Jann. Estout is package installable through SSC to output tables in Word-format.
That guide provides this example code as the correct way to achieve what I want:
Code:
estpost tabstat price mpg rep78, by(foreign) statistics(mean sd) /// columns(statistics) listwise esttab, main(mean) aux(sd) nostar unstack noobs nonote nomtitle nonumber
Code:
eststo clear estpost tabstat EEC_1 EEC_2 EEC_3 EEC_4 EEC_5, by(category) statistics(mean sd) nototal listwise esttab using "EEC_table.rtf", main(mean) aux(sd) wide label nostar title("Estimated electricity consumption by year and group")
Using the command:
Code:
ereturn list
Code:
scalars: e(N) = 47409 macros: e(cmd) : "estpost" e(subcmd) : "tabstat" e(stats) : "count mean semean" e(vars) : "EEC_1 EEC_2 EEC_3 EEC_4 EEC_5" e(byvar) : "category" matrices: e(EEC_1) : 1 x 9 e(EEC_2) : 1 x 9 e(EEC_3) : 1 x 9 e(EEC_4) : 1 x 9 e(EEC_5) : 1 x 9
It only displays the number of observations in the dataset, while I want it to display the mean and standard errors of EEC_1 to EEC_5 by category. Does anyone know what I'm doing wrong?
This is what my data looks like:
Code:
* Example generated by -dataex-. To install: ssc install dataex, clear input float id int year float(EEC_1 EEC_2 EEC_3 EEC_4 EEC_5) 3 2001 11.11309 -39.40571 -36.844822 -35.25638 -6.324554 3 2002 -39.40571 -36.844822 -35.25638 -6.324554 -6.090625 3 2003 -36.844822 -35.25638 -6.324554 -6.090625 25.30633 3 2004 -35.25638 -6.324554 -6.090625 25.30633 -2.747145 3 2005 -6.324554 -6.090625 25.30633 -.6391789 -.6391789 3 2006 -6.090625 25.30633 -2.747145 -2.747145 -2.747145 3 2007 25.30633 -.6391789 -.6391789 -.6391789 -.6391789 3 2008 -.6391789 -.6391789 -.6391789 -.6391789 -.6391789 6 2004 -38.28638 -21.004555 -28.450626 -44.65367 -2.747145 6 2005 -21.004555 -28.450626 -44.65367 -2.747145 -2.747145 6 2006 -28.450626 -44.65367 -2.747145 -2.747145 -2.747145 6 2007 -44.65367 1.9308683 1.9308683 1.9308683 1.9308683 6 2008 -.6391789 -.6391789 -.6391789 -.6391789 -.6391789 8 2011 -2.4298 97.9789 -7.716767 -23.06271 -69.559235 8 2012 97.9789 -7.716767 -23.06271 -69.559235 .6788008 8 2013 -7.716767 -23.06271 -69.559235 .6788008 .6788008 8 2014 -23.06271 -69.559235 .6788008 .6788008 .6788008 8 2015 -69.559235 .6788008 .6788008 .6788008 .6788008 8 2016 .6788008 .6788008 .6788008 .6788008 .6788008 10 2004 -30.61538 -36.341553 17.248375 -7.098672 .6788008 10 2005 -36.341553 17.248375 -7.098672 -2.747145 -2.747145 10 2006 17.248375 -7.098672 -.6391789 -.6391789 -.6391789 10 2007 -7.098672 -2.747145 -2.747145 -2.747145 -2.747145 10 2008 -.6391789 -.6391789 -.6391789 -.6391789 -.6391789 10 2011 11.3852 -27.0081 37.92723 35.33629 .7077668 10 2012 -27.0081 37.92723 35.33629 .7077668 59.23471 10 2013 37.92723 35.33629 .7077668 59.23471 .6788008 10 2014 35.33629 .7077668 59.23471 .6788008 .6788008 10 2015 .7077668 59.23471 .6788008 .6788008 .6788008 10 2016 59.23471 .6788008 .6788008 .6788008 .6788008 10 2017 .6788008 .6788008 .6788008 .6788008 .6788008 12 2002 -19.091705 -18.050821 66.60662 34.640446 92.63937 12 2003 -18.050821 66.60662 34.640446 92.63937 -19.52367 12 2004 66.60662 34.640446 92.63937 -19.52367 -23.92541 12 2005 34.640446 92.63937 -19.52367 -23.92541 -29.87683 12 2006 92.63937 -19.52367 -23.92541 -29.87683 -3.214347 12 2007 -19.52367 -23.92541 -29.87683 -3.214347 -7.0178 12 2008 -23.92541 -29.87683 -3.214347 -7.0178 .16489896 12 2009 -29.87683 -3.214347 -7.0178 .16489896 -5.053768 12 2010 -3.214347 -7.0178 .16489896 -5.053768 23.04429 12 2011 -7.0178 .16489896 -5.053768 23.04429 -16.004232 12 2012 .16489896 -5.053768 23.04429 -16.004232 9.203712 12 2013 -5.053768 23.04429 -16.004232 9.203712 -.6391789 12 2014 23.04429 -16.004232 9.203712 -.6391789 -.6391789 12 2015 -16.004232 9.203712 -.6391789 -.6391789 -.6391789 12 2016 9.203712 -.6391789 -.6391789 -.6391789 -.6391789 12 2017 -.6391789 -.6391789 -.6391789 -.6391789 -.6391789 14 2002 -2.747145 -2.747145 -2.747145 -2.747145 -2.747145 14 2004 75.30222 12.485146 43.10167 -40.87957 -8.994008 14 2005 12.485146 43.10167 -40.87957 -8.994008 2.0384722 14 2006 43.10167 -40.87957 -8.994008 2.0384722 -13.936147 14 2007 -40.87957 -8.994008 2.0384722 -13.936147 -2.747145 14 2008 -8.994008 2.0384722 -13.936147 -.6391789 -.6391789 14 2009 2.0384722 -13.936147 1.9308683 1.9308683 1.9308683 14 2010 -13.936147 -.6391789 -.6391789 -.6391789 -.6391789 14 2011 -.6391789 -.6391789 -.6391789 -.6391789 -.6391789 14 2014 -4.7423115 -.6391789 -.6391789 -.6391789 -.6391789 14 2015 .6788008 .6788008 .6788008 .6788008 .6788008 14 2017 .6788008 .6788008 .6788008 .6788008 .6788008 15 1996 11.390562 -49.40996 -25.13894 -42.82194 -28.27622 15 1997 -49.40996 -25.13894 -42.82194 -28.27622 93.61309 15 1998 -25.13894 -42.82194 -28.27622 93.61309 60.67429 15 1999 -42.82194 -28.27622 93.61309 60.67429 -15.73482 15 2000 -28.27622 93.61309 60.67429 -15.73482 -17.026377 15 2001 93.61309 60.67429 -15.73482 -17.026377 -1.4445542 15 2002 60.67429 -15.73482 -17.026377 -1.4445542 -45.19063 15 2003 -15.73482 -17.026377 -1.4445542 -45.19063 54.77633 15 2004 -17.026377 -1.4445542 -45.19063 54.77633 35.498592 15 2005 -1.4445542 -45.19063 54.77633 35.498592 -32.376827 15 2006 -45.19063 54.77633 35.498592 -32.376827 -22.799347 15 2007 54.77633 35.498592 -32.376827 -22.799347 10.1802 15 2008 35.498592 -32.376827 -22.799347 10.1802 -51.2211 15 2009 -32.376827 -22.799347 10.1802 -51.2211 -18.956768 15 2010 -22.799347 10.1802 -51.2211 -18.956768 98.88729 15 2011 10.1802 -51.2211 -18.956768 98.88729 1.390767 15 2012 -51.2211 -18.956768 98.88729 1.390767 13.022712 15 2013 -18.956768 98.88729 1.390767 13.022712 1.9308683 15 2014 98.88729 1.390767 13.022712 1.9308683 1.9308683 15 2015 1.390767 13.022712 1.9308683 1.9308683 1.9308683 15 2016 13.022712 1.9308683 1.9308683 1.9308683 1.9308683 15 2017 1.9308683 1.9308683 1.9308683 1.9308683 1.9308683 19 1995 -38.17665 -63.03944 -2.747145 -2.747145 -2.747145 19 1996 -63.03944 -.6391789 -.6391789 -.6391789 -.6391789 19 1997 -.6391789 -.6391789 -.6391789 -.6391789 -.6391789 19 1999 -74.74194 -30.426226 -79.10691 -38.56571 -2.747145 19 2000 -30.426226 -79.10691 -38.56571 -2.747145 -2.747145 19 2001 -79.10691 -38.56571 -.6391789 -.6391789 -.6391789 19 2002 -38.56571 -.6391789 -.6391789 -.6391789 -.6391789 19 2003 -.6391789 -.6391789 -.6391789 -.6391789 -.6391789 20 1997 29.94004 -72.14893 22.01806 -13.876224 -2.747145 20 1998 -72.14893 22.01806 -13.876224 -2.747145 -2.747145 20 1999 22.01806 -13.876224 -2.747145 -2.747145 -2.747145 20 2000 -13.876224 -.6391789 -.6391789 -.6391789 -.6391789 20 2001 -2.747145 -2.747145 -2.747145 -2.747145 -2.747145 20 2003 -5.764822 -21.026377 4.455446 -.6391789 -.6391789 20 2004 -21.026377 4.455446 -.6391789 -.6391789 -.6391789 20 2005 4.455446 1.9308683 1.9308683 1.9308683 1.9308683 20 2006 -2.747145 -2.747145 -2.747145 -2.747145 -2.747145 21 1995 -26.65666 -31.629436 37.32004 7.181062 -15.39194 21 1996 -31.629436 37.32004 7.181062 -15.39194 71.04378 end
Comment