The estpost and esttab commands are from the estout package on SSC.
I use estpost summarize to make summary statistics tables.
I am told that readers prefer decimals as fixed width/precision.
Say, a leading zero and three decimal places.
Option fmt(%9.3f) gives a leading zero and fixed width,
but reports large numbers without commas.
Option fmt(%12.3gc) gives commas,
but does not report fixed width decimals.
Is there a way to be more granular with fmt() in esttab?
Say, use %12.3gc for numbers above some threshold and %9.3f otherwise?
This may create problems that I have not anticipated.
Here is an example of how I use estpost summarize and the shortcomings of each approach.
sysuse auto, clear
expand 1000
eststo clear
estpost summarize price rep78, detail
eststo
/* gives mean/median/SD with fixed number of decimals */
/* but must manually add commas to large numbers (price) */
local rightwidth_nocommas ///
label noobs nonumbers nomtitles ///
cell("count(fmt(%9.3gc) label(Obs.)) mean(fmt(%9.3f) label(Mean)) p50(fmt(%9.3f) label(Median)) sd(fmt(%9.3f) label(Std. Dev.))")
esttab, `rightwidth_nocommas'
. esttab, `rightwidth_nocommas'
------------------------------------------------------------------------
Obs. Mean Median Std. Dev.
------------------------------------------------------------------------
Price 74,000 6165.257 5006.500 2929.519
Repair Record 1978 69,000 3.406 3.000 0.983
------------------------------------------------------------------------
/* gives commas to large numbers (price) */
/* but must pad mean/median/SD to get a fixed number of decimals */
local commas_wrongwidth ///
label noobs nonumbers nomtitles ///
cell("count(fmt(%9.3gc) label(Obs.)) mean(fmt(%9.3gc) label(Mean)) p50(fmt(%9.3gc) label(Median)) sd(fmt(%9.3gc) label(Std. Dev.))")
esttab, `commas_wrongwidth'
. esttab, `commas_wrongwidth'
------------------------------------------------------------------------
Obs. Mean Median Std. Dev.
------------------------------------------------------------------------
Price 74,000 6,165 5,007 2,930
Repair Record 1978 69,000 3.41 3 .983
------------------------------------------------------------------------
%9.3fcto get numbers with 3 places to the right of the decimal, and commas in large numbers to the left of the decimal? - user4690969%9.3fcbefore forNin thestats()option, but it didn't work (i.e., no comma, but fixed decimal). So for counts,%9.3fcinesttabgivesXXXX.XXX(no comma), but for non-counts,%9.3fcinesttabgivesX,XXX.XXX, which is what I want. TLDR use9.3gcfor counts,%9.3fcfor everything else. - Richard Herron