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: Summary statistics table
From
Joseph Monte <[email protected]>
To
statalist <[email protected]>
Subject
st: Summary statistics table
Date
Tue, 26 Feb 2013 11:40:43 +0000
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)'
}
}
-------------------------------
Thanks,
Joe
*
* 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/