Span multicolumn stats for LaTeX table with esttab/estout
up vote
3
down vote
favorite
I would like to be able to center a statistic over multiple columns when using esttab.
In my toy example, I would like N to span two columns:
sysuse auto, clear
est clear
qui estpost sum if foreign == 1
qui est store sum_foreign
qui estpost sum
qui est store sum_all
esttab sum_foreign sum_all, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
stats(N, ///
fmt(%9.0fc) ///
label("Observations"))
Though the toy example just uses Stata's output, in general I would like to do this in LaTeX.
For other pieces of the table (collabels, mgroups etc.) you can specify the pattern() argument, which allows you to span, but this is not an option for stats().
Does anyone know how I can make the observation count span the width of the model (2 columns)?
latex stata
add a comment |
up vote
3
down vote
favorite
I would like to be able to center a statistic over multiple columns when using esttab.
In my toy example, I would like N to span two columns:
sysuse auto, clear
est clear
qui estpost sum if foreign == 1
qui est store sum_foreign
qui estpost sum
qui est store sum_all
esttab sum_foreign sum_all, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
stats(N, ///
fmt(%9.0fc) ///
label("Observations"))
Though the toy example just uses Stata's output, in general I would like to do this in LaTeX.
For other pieces of the table (collabels, mgroups etc.) you can specify the pattern() argument, which allows you to span, but this is not an option for stats().
Does anyone know how I can make the observation count span the width of the model (2 columns)?
latex stata
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I would like to be able to center a statistic over multiple columns when using esttab.
In my toy example, I would like N to span two columns:
sysuse auto, clear
est clear
qui estpost sum if foreign == 1
qui est store sum_foreign
qui estpost sum
qui est store sum_all
esttab sum_foreign sum_all, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
stats(N, ///
fmt(%9.0fc) ///
label("Observations"))
Though the toy example just uses Stata's output, in general I would like to do this in LaTeX.
For other pieces of the table (collabels, mgroups etc.) you can specify the pattern() argument, which allows you to span, but this is not an option for stats().
Does anyone know how I can make the observation count span the width of the model (2 columns)?
latex stata
I would like to be able to center a statistic over multiple columns when using esttab.
In my toy example, I would like N to span two columns:
sysuse auto, clear
est clear
qui estpost sum if foreign == 1
qui est store sum_foreign
qui estpost sum
qui est store sum_all
esttab sum_foreign sum_all, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
stats(N, ///
fmt(%9.0fc) ///
label("Observations"))
Though the toy example just uses Stata's output, in general I would like to do this in LaTeX.
For other pieces of the table (collabels, mgroups etc.) you can specify the pattern() argument, which allows you to span, but this is not an option for stats().
Does anyone know how I can make the observation count span the width of the model (2 columns)?
latex stata
latex stata
edited Nov 7 at 18:54
Pearly Spencer
8,902163352
8,902163352
asked Nov 7 at 18:03
Alexander Vornsand
204
204
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You need to manually insert the required spacing between each statistic with estadd, using the appropriate LaTeX markup as a prefix. This is necessary in order to typeset the table correctly.
The following works for me:
sysuse auto, clear
est clear
estpost sum if foreign == 1
local N1 hspace{1.2cm}`e(N)'
estadd local NA `N1'
est store sum_foreign
estpost sum
local N2 hspace{2cm}`e(N)'
estadd local NA `N2'
est store sum_all
esttab sum_foreign sum_all using table.tex, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
stats(NA, ///
fmt(%9.0fc) ///
label("Observations"))
EDIT:
Here's another way of doing this but with automatic centering of the observation numbers:
sysuse auto, clear
est clear
estpost sum if foreign == 1
local N1 &multicolumn{2}{c}{`e(N)'}
estadd local NA `N1'
est store sum_foreign
estpost sum
local N2 &multicolumn{2}{c}{`e(N)'}
estadd local NA `N2'
est store sum_all
esttab sum_foreign sum_all using table.tex, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
postfoot("hline Observations: `N1' `N2' \ hlinehline \ end{tabular} \ }")
Thanks for the suggestion, @Pearly Spencer. This seems like an okay approximation, but I'd like to find a solution that more precisely centers the statistic if it's possible (or is something that can be generalized).
– Alexander Vornsand
Nov 7 at 18:58
@AlexanderVornsand see the edit in my answer for a slightly more generalized solution.
– Pearly Spencer
Nov 7 at 22:18
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You need to manually insert the required spacing between each statistic with estadd, using the appropriate LaTeX markup as a prefix. This is necessary in order to typeset the table correctly.
The following works for me:
sysuse auto, clear
est clear
estpost sum if foreign == 1
local N1 hspace{1.2cm}`e(N)'
estadd local NA `N1'
est store sum_foreign
estpost sum
local N2 hspace{2cm}`e(N)'
estadd local NA `N2'
est store sum_all
esttab sum_foreign sum_all using table.tex, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
stats(NA, ///
fmt(%9.0fc) ///
label("Observations"))
EDIT:
Here's another way of doing this but with automatic centering of the observation numbers:
sysuse auto, clear
est clear
estpost sum if foreign == 1
local N1 &multicolumn{2}{c}{`e(N)'}
estadd local NA `N1'
est store sum_foreign
estpost sum
local N2 &multicolumn{2}{c}{`e(N)'}
estadd local NA `N2'
est store sum_all
esttab sum_foreign sum_all using table.tex, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
postfoot("hline Observations: `N1' `N2' \ hlinehline \ end{tabular} \ }")
Thanks for the suggestion, @Pearly Spencer. This seems like an okay approximation, but I'd like to find a solution that more precisely centers the statistic if it's possible (or is something that can be generalized).
– Alexander Vornsand
Nov 7 at 18:58
@AlexanderVornsand see the edit in my answer for a slightly more generalized solution.
– Pearly Spencer
Nov 7 at 22:18
add a comment |
up vote
1
down vote
accepted
You need to manually insert the required spacing between each statistic with estadd, using the appropriate LaTeX markup as a prefix. This is necessary in order to typeset the table correctly.
The following works for me:
sysuse auto, clear
est clear
estpost sum if foreign == 1
local N1 hspace{1.2cm}`e(N)'
estadd local NA `N1'
est store sum_foreign
estpost sum
local N2 hspace{2cm}`e(N)'
estadd local NA `N2'
est store sum_all
esttab sum_foreign sum_all using table.tex, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
stats(NA, ///
fmt(%9.0fc) ///
label("Observations"))
EDIT:
Here's another way of doing this but with automatic centering of the observation numbers:
sysuse auto, clear
est clear
estpost sum if foreign == 1
local N1 &multicolumn{2}{c}{`e(N)'}
estadd local NA `N1'
est store sum_foreign
estpost sum
local N2 &multicolumn{2}{c}{`e(N)'}
estadd local NA `N2'
est store sum_all
esttab sum_foreign sum_all using table.tex, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
postfoot("hline Observations: `N1' `N2' \ hlinehline \ end{tabular} \ }")
Thanks for the suggestion, @Pearly Spencer. This seems like an okay approximation, but I'd like to find a solution that more precisely centers the statistic if it's possible (or is something that can be generalized).
– Alexander Vornsand
Nov 7 at 18:58
@AlexanderVornsand see the edit in my answer for a slightly more generalized solution.
– Pearly Spencer
Nov 7 at 22:18
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You need to manually insert the required spacing between each statistic with estadd, using the appropriate LaTeX markup as a prefix. This is necessary in order to typeset the table correctly.
The following works for me:
sysuse auto, clear
est clear
estpost sum if foreign == 1
local N1 hspace{1.2cm}`e(N)'
estadd local NA `N1'
est store sum_foreign
estpost sum
local N2 hspace{2cm}`e(N)'
estadd local NA `N2'
est store sum_all
esttab sum_foreign sum_all using table.tex, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
stats(NA, ///
fmt(%9.0fc) ///
label("Observations"))
EDIT:
Here's another way of doing this but with automatic centering of the observation numbers:
sysuse auto, clear
est clear
estpost sum if foreign == 1
local N1 &multicolumn{2}{c}{`e(N)'}
estadd local NA `N1'
est store sum_foreign
estpost sum
local N2 &multicolumn{2}{c}{`e(N)'}
estadd local NA `N2'
est store sum_all
esttab sum_foreign sum_all using table.tex, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
postfoot("hline Observations: `N1' `N2' \ hlinehline \ end{tabular} \ }")
You need to manually insert the required spacing between each statistic with estadd, using the appropriate LaTeX markup as a prefix. This is necessary in order to typeset the table correctly.
The following works for me:
sysuse auto, clear
est clear
estpost sum if foreign == 1
local N1 hspace{1.2cm}`e(N)'
estadd local NA `N1'
est store sum_foreign
estpost sum
local N2 hspace{2cm}`e(N)'
estadd local NA `N2'
est store sum_all
esttab sum_foreign sum_all using table.tex, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
stats(NA, ///
fmt(%9.0fc) ///
label("Observations"))
EDIT:
Here's another way of doing this but with automatic centering of the observation numbers:
sysuse auto, clear
est clear
estpost sum if foreign == 1
local N1 &multicolumn{2}{c}{`e(N)'}
estadd local NA `N1'
est store sum_foreign
estpost sum
local N2 &multicolumn{2}{c}{`e(N)'}
estadd local NA `N2'
est store sum_all
esttab sum_foreign sum_all using table.tex, ///
replace ///
cells("mean(fmt(3)) sd(fmt(3))") ///
nonum ///
collabels("Mean" "SD") ///
label ///
noobs ///
drop(make) ///
postfoot("hline Observations: `N1' `N2' \ hlinehline \ end{tabular} \ }")
edited Nov 7 at 22:17
answered Nov 7 at 18:41
Pearly Spencer
8,902163352
8,902163352
Thanks for the suggestion, @Pearly Spencer. This seems like an okay approximation, but I'd like to find a solution that more precisely centers the statistic if it's possible (or is something that can be generalized).
– Alexander Vornsand
Nov 7 at 18:58
@AlexanderVornsand see the edit in my answer for a slightly more generalized solution.
– Pearly Spencer
Nov 7 at 22:18
add a comment |
Thanks for the suggestion, @Pearly Spencer. This seems like an okay approximation, but I'd like to find a solution that more precisely centers the statistic if it's possible (or is something that can be generalized).
– Alexander Vornsand
Nov 7 at 18:58
@AlexanderVornsand see the edit in my answer for a slightly more generalized solution.
– Pearly Spencer
Nov 7 at 22:18
Thanks for the suggestion, @Pearly Spencer. This seems like an okay approximation, but I'd like to find a solution that more precisely centers the statistic if it's possible (or is something that can be generalized).
– Alexander Vornsand
Nov 7 at 18:58
Thanks for the suggestion, @Pearly Spencer. This seems like an okay approximation, but I'd like to find a solution that more precisely centers the statistic if it's possible (or is something that can be generalized).
– Alexander Vornsand
Nov 7 at 18:58
@AlexanderVornsand see the edit in my answer for a slightly more generalized solution.
– Pearly Spencer
Nov 7 at 22:18
@AlexanderVornsand see the edit in my answer for a slightly more generalized solution.
– Pearly Spencer
Nov 7 at 22:18
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53195216%2fspan-multicolumn-stats-for-latex-table-with-esttab-estout%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown