Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

Re: st: Summary statistics table

From   Nick Cox <>
To   "" <>
Subject   Re: st: Summary statistics table
Date   Tue, 26 Feb 2013 11:54:10 +0000

Use -search- to find the appropriate commands. Statalist is being abused if there is no sign that you have made any effort to work this out first.


On 26 Feb 2013, at 11:40, Joseph Monte <> wrote:

Dear Statalisters,

I am using the code below to get the number of observations, mean, and
p-value of t-test of two groups. In addition, I need the median of
each group (in the column just after the respective mean) and the
p-value of the rank sum test (in the column just after the p-value of
the t-test). I would appreciate any help with the code for these
additional items. Also, can I export this table directly into
Microsoft Excel? I am using Stata 12.

sysuse auto, clear

qui {

noi di "Variable`=char(9)'N1`=char(9)'Mean1`=char(9)'N2`=char (9)'Mean2`=char(9)'p-value"

foreach var of varlist price  mpg weight  {
cap ttest `var', by(foreign) unequal

noi di as text "`var'`=char(9)'" as result %8.0f `r(N_1)' "`=char(9)'"
%8.2f `r(mu_1)' "`=char(9)'" %8.0f `r(N_2)' "`=char(9)'" %8.2f
`r(mu_2)' %8.2f `r(p)'

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index