I let STATA display summary statistics for me using esttab, as follows:
Code:
sysuse auto, clear
local sumvars mpg headroom gear_ratio
estpost tabstat `sumvars', s(n mean p50 min max sd) col(stat)
esttab . , ///
c("mean(fmt(3)) p50(fmt(3)) sd(fmt(3)) min(fmt(3)) max(fmt(3)) count(fmt(0))") label noobs nodepvar nomtitle nonumber replace tex ///
coeflabels()
Now, I would like to twist the formatting in a way that a number, say the minimum of one of the variables, is displayed with three digits only if it is NOT an integer. For example, the min of Mileage(mpg) is 12, so I would like esttab to produce "12" rather than "12.000". Similarly, the min of Gear Ratio is 2.190, so there, it is fine to have three digits, because 2.190 is not an integer. Of course I could check this manually, but it would be much faster and safer to have STATA do this for me. Can I tweak the format to achieve this?
0 Response to Number format: only display digits if non-intenger
Post a Comment