Hi all,
When using esttab to output statistics created by multiple tabstat commands, there are times when one or more of the cells defined by the tabstat’s by(varname) will be empty. This does not normally create an issue even when combining multiple tabstat estimates, some with and some without empty cells. However, if there is a space in the label values of the tabstat by variable, the output can become incorrectly formatted. For example, this code produces correct results.
However, if I add a space to five or more, I get this.
Obviously I can work around this by not using spaces in
When using esttab to output statistics created by multiple tabstat commands, there are times when one or more of the cells defined by the tabstat’s by(varname) will be empty. This does not normally create an issue even when combining multiple tabstat estimates, some with and some without empty cells. However, if there is a space in the label values of the tabstat by variable, the output can become incorrectly formatted. For example, this code produces correct results.
Code:
#delimit ;
sysuse auto;
label define rep78 1 "One" 2 "Two" 3 "Three" 4 "Four" 5 "Five-or-more";
label values rep78 rep78;
eststo : estpost tabstat price if foreign==0, by(rep78)
statistics(n mean semean) columns(statistics) nototal;
eststo : estpost tabstat price if foreign==1, by(rep78)
statistics(n mean semean) columns(statistics) nototal;
esttab ,
cells(mean(fmt(%12.3f)) semean(fmt(%12.3f) par(( ))))
replace label unstack noobs nonumbers collabels(none)
mlabels("Domestic" "Foreign") nomtitles nonotes;
eststo clear;
----------------------------------------------
Domestic Foreign
----------------------------------------------
One 4564.500
(369.500)
Two 5967.625
(1265.494)
Three 6607.074 4828.667
(704.611) (742.249)
Four 5881.556 6261.444
(530.673) (632.031)
Five-or-more 4204.500 6292.667
(220.500) (921.876)
----------------------------------------------
However, if I add a space to five or more, I get this.
Code:
label define rep78 5 "Five or more", modify;
eststo : estpost tabstat price if foreign==0, by(rep78)
statistics(n mean semean) columns(statistics) nototal;
eststo : estpost tabstat price if foreign==1, by(rep78)
statistics(n mean semean) columns(statistics) nototal;
esttab ,
cells(mean(fmt(%12.3f)) semean(fmt(%12.3f) par(( ))))
replace label unstack noobs nonumbers collabels(none)
mlabels("Domestic" "Foreign") nomtitles nonotes;
eststo clear;
----------------------------------------------
Domestic Foreign
----------------------------------------------
One 4564.500
(369.500)
Two 5967.625
(1265.494)
Three 6607.074 4828.667
(704.611) (742.249)
Four 5881.556 6261.444
(530.673) (632.031)
Five or more 4204.500
(220.500)
Five 6292.667
(921.876)
----------------------------------------------
Obviously I can work around this by not using spaces in
label values, but is there a solution that will allow me to include the spaces?

Comment