Suppose that I have this data:
sysuse auto2, clear
For two different samples, I can use the community-contributed command esttab
to create a table of means a
and b
with standard deviations in parentheses below the means:
eststo clear
eststo a: estpost summarize trunk weight length turn
keep if inrange(mpg, 12, 20)
eststo b: estpost summarize trunk weight length turn
esttab a b, label cells("mean(fmt(2))" "sd(fmt(2) par)") ///
nonumbers booktabs collabels("a" "b")
I want the produced table to have the two columns above exactly as is, but then to add additional summary statistics (here min
and max
) corresponding to the b
estimates.
For example, I want the third column to be like:
esttab b, label cells("min") ///
nonumbers booktabs collabels("min")
In addition, I would like the fourth column to be as follows:
esttab b, label cells("max") ///
nonumbers booktabs collabels("min")
The problem is that I am not sure how to make all of this be in one table together (other than perhaps saving everything to a matrix and using esttab
on that).
The reason is that it does not seem like one can get the cells
option to correspond to an individual column; it applies the changes to all columns.
Note that if there is a way to do this, but it would require the s.d.s to not be included, that is fine.
How can I generate the desired output without creating a matrix?
This is the best you can do without creating a matrix:
esttab a b, label cells( (mean(fmt(2)) min max) sd(fmt(2) par) )
--------------------------------------------------------------------------------------------------
(1) (2)
mean/sd min max mean/sd min max
--------------------------------------------------------------------------------------------------
Trunk space (.. ft.) 13.76 5.00 23.00 16.32 7.00 23.00
(4.28) (3.28)
Weight (lbs.) 3019.46 1760.00 4840.00 3558.68 2410.00 4840.00
(777.19) (498.89)
Length (in.) 187.93 142.00 233.00 203.89 173.00 233.00
(22.27) (13.87)
Turn Circle (ft.) 39.65 31.00 51.00 42.55 36.00 51.00
(4.40) (3.21)
--------------------------------------------------------------------------------------------------
Observations 74 38
--------------------------------------------------------------------------------------------------