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]

Re: st: Summary statistics table


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
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.

Nick

On 26 Feb 2013, at 11:40, Joseph Monte <[email protected]> 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:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index