Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: combining summary and correlation tables using estout


From   Ben Jann <[email protected]>
To   [email protected]
Subject   Re: st: combining summary and correlation tables using estout
Date   Mon, 31 Aug 2009 22:27:58 +0200

I think you need a bit of programming here. I have two solutions.

Solution 1: Add the correlations, column by column, to the estimation
set holding the summary statistics

sysuse auto, clear
local vlist price mpg weight
eststo SUM: estpost sum `vlist'
estpost corr `vlist', matrix
matrix corr = e(b)
foreach var of local vlist {
	matrix tmp = corr[1...,"`var':"]
	matrix coleq tmp = ":"
	estadd matrix `var' = tmp: SUM
}
estout SUM, cell("mean sd price mpg weight")

Solution 2: Make one big vector containing the correlations and
summary statistics and use equation names to define the columns

sysuse auto, clear
local vlist price mpg weight
estpost corr `vlist', matrix
matrix b = e(b)
estpost sum `vlist'
foreach stat in mean sd {
	matrix tmp = e(`stat')
	matrix coleq tmp = `stat'
	matrix b = b, tmp
}
ereturn post b
estout ., unstack

Type, e.g.

estout ., order(mean: sd:) unstack

to change the order.

ben


On Mon, Aug 31, 2009 at 1:40 PM, Matthijs De Zwaan<[email protected]> wrote:
> Dear Stata listers,
> I'm trying to produce a combined summary and correlation table using
> estout. My idea is to get something similar to -corr, mean-, but with
> the tables aligned rather than stacked on top of each other. I know
> how to make the correlation and summary tables separately using the
> -estpost summ/corr/tabstat- commands, but I cannot manage to put the
> two together the way I want.
>
> I have saved the summary table under SUMM and the correlation table as
> CORR. When I try to put them together, I use -estout SUMM CORR,
> cells(…relevant statistics…)- to get the output for the summary table,
> but then the correlation table is empty. I cannot figure out what I
> need to specify to get the correlation table pasted next to it. Does
> anyone know how to do this?
>
> Thanks,
> Matthijs
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index