Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Creating Descriptive Statistics With Estpost & Tabstat


From   Austin Nichols <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Creating Descriptive Statistics With Estpost & Tabstat
Date   Wed, 3 Nov 2010 22:11:48 -0400

Matthew Krauchunas <[email protected]> :

Reframing in terms of a dataset anyone can use, you want to transpose this:

sysuse auto, clear
g year=rep78+2000
tabstat turn trunk, statistics(mean sd) by(year)

which can be done using -tabstatmat- (SSC) as you allude to, or using
-estout- (SSC) like so:

clear all
sysuse auto
g year=rep78+2000
qui levelsof year, loc(levs)
qui foreach v of loc levs {
 estpost summ turn trunk if year==`v'
 est sto CY`v'
 }
esttab *, cell(mean sd(par)) mti
esttab *, cell(mean sd(par)) mti collabels(none) nonum noobs
tabstat turn trunk, statistics(mean sd) by(year)

and note that the -estout- solution can also be written out to a file easily.

OTOH, the -tabstatmat- solution feeds into -xml_tab- (SSC) nicely...
useful if you are an Excel user.

On Wed, Nov 3, 2010 at 8:30 PM, Matthew Krauchunas
<[email protected]> wrote:
> Hello,
>
> I am trying to create a table of means and standard deviations (in
> parentheses) similar to this format:
>
> Variable_Name     2002     2003    2004
> ---------------------------------------------------------
> rn_hprd                .271      .265     .258
>                          (.157)     (.159)   (.159)
> -----------------------------------------------------------
> lvn_hprd              .60         .62       .64
>                          (.180)     (.181)    (.186)
> -----------------------------------------------------------
>
> I have tried tabstat, but the years are the rows instead of the columns:
> .   tabstat  rn_hprd_adj  lvn_hprd_adj, statistics( mean sd) by(year)
> columns(variables)
>
>    year |  rn_~_adj  lvn~_adj
> ---------+--------------------
>    2002 |  .2761311  .6059625
>         |  .1649422  .1979371
> ---------+--------------------
>    2003 |  .2721822  .6346036
>         |   .168225  .2034016
> ---------+--------------------
>    2004 |   .264628   .654483
>         |  .1695155    .21293
> ---------+--------------------
>    2006 |  .2752124  .7032399
>         |  .1779005  .2163748
> ---------+--------------------
>    2007 |   .276638   .739869
>         |  .1788564  .2327166
> ---------+--------------------
>   Total |  .2729584  .6676316
>         |  .1719123  .2182212
> ------------------------------
>
> I have also tried a combination of estpost & tabstat which appears to
> be a nice format, but again the same problem:
> estpost tabstat  rn_hprd_adj lvn_hprd_adj, statistics( mean sd)
> by(year) columns(variables)
>
>        year | e(rn_hp~)  e(lvn_h~)
> -------------+----------------------
> 2002         |
>        mean |  .2761311   .6059625
>          sd |  .1649422   .1979371
> -------------+----------------------
> 2003         |
>        mean |  .2721822   .6346036
>          sd |   .168225   .2034016
> -------------+----------------------
> 2004         |
>        mean |   .264628    .654483
>          sd |  .1695155     .21293
> -------------+----------------------
> 2006         |
>        mean |  .2752124   .7032399
>          sd |  .1779005   .2163748
> -------------+----------------------
> 2007         |
>        mean |   .276638    .739869
>          sd |  .1788564   .2327166
> -------------+----------------------
> Total        |
>        mean |  .2729584   .6676316
>          sd |  .1719123   .2182212
>
> I saw a potential solution to Mr. Nick Cox by transposing a matrix
> (http://www.stata.com/statalist/archive/2006-08/msg00335.html), but I
> cannot quite figure it out.
>
> Does anyone have any suggestions on how to create this type of table?

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index