Statalist


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

Re: st: Making tables with ttest


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Making tables with ttest
Date   Mon, 1 Feb 2010 16:25:30 +0000 (GMT)

--- On Mon, 1/2/10, Nuno Soares wrote:
> I was wondering if there is a way of building tables in
> Stata with a set of -ttest- results for different
> variables. The table would look something like this
> (produced in SAS, and testing for H0: mean=0):

*------------------- begin example ---------------------
sysuse auto, clear
matrix res = J(3,4,.)
local i = 1
local rown ""
foreach var of varlist mpg rep78 trunk {
	ttest `var' = 0
	matrix res[`i++',1] = r(N_1), r(mu_1), r(t), r(p)
	local rown "`rown' `var'"
}

matrix rownames res = `rown'
matrix colnames res = N Mean t_Value Pr_>_|t|
matlist res, underscore format(%9.3g)
*------------------- end example --------------------------
( For more on how to use examples I sent to statalist see:
 http://www.maartenbuis.nl/stata/exampleFAQ.html )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index