Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Numerous t-tests


From   Henrik Stovring <[email protected]>
To   [email protected]
Subject   Re: st: Numerous t-tests
Date   Wed, 26 Oct 2005 12:40:54 +0200

Allan Garland wrote:
> I have what should be a very simple question, but I haven't been able to
> figure out the answer.  I want to do group mean comparison t-tests and
> rank sum tests on a number of different variables..  But, it appears
> that both -ttest- and -ranksum- will only do 1 variable at a time.  So,
> is there a single command that will let me put in any number of
> variables (along with the 2-level grouping variable, of course) and will
> then do ALL the tests at once?
> 

The easiest angle of attack is probably:

foreach outcomevar of varlist [outvar1 outvar2 ...] {
	foreach grpvar of varlist [grpvar1 grpvar2 ...] {
		ttest `outcomevar', by(`grpvar')
		ranksum `outcomevar', by(`grpvar')
	}
}

where of course you need to provide suitable variable names for outvar1,
grpvar1, etc., see -help varlist- . For more information see -help foreach-

Best,

Henrik
-- 
Henrik St�vring, PhD

Research Unit of General Practice
University of Southern Denmark
J.B. Winsl�ws Vej 9
DK-5000 Odense C
Phone: (+45) 6550 3692
Fax: (+45) 6591 8296
email: [email protected]
Homepage: http://www.biostat.sdu.dk/~stovring
------------------------------------------------------------------
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index