Re: st: Displaying ttest results

 From Fred Wolfe To statalist@hsphsun2.harvard.edu Subject Re: st: Displaying ttest results Date Sat, 19 Aug 2006 09:13:41 -0500

This comes up often enough that Stata should fix the output display. But until that time make the following change:

foreach var in var1 var2 var3 var4 ... {
di "`var'"
ttest `var', by(group)
}

At 08:47 AM 8/19/2006, you wrote:

Hi,

i am using ttest to test the equality of variables across a group, i.e.

foreach var in var1 var2 var3 var4 ... {
ttest `var', by(group)
}

When it displays the results for each variable, it gives the standard ttest table (see below) without mentioning the variable it refers to. Of course, I can figure it out by counting which table it is in the list (i.e. if it's the 13th table, it must be testing equality of the 13th variable) but is there a smart way to do it so that it lists the variable being tested in the table header?

Thanks,
YC

Two-sample t test with equal variances
------------------------------------------------------------------------------
Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval]
---------+--------------------------------------------------------------------
0 | 6713 .0121423 .0010673 .0874496 .01005
.0142346
1 | 5748 .0029847 .0010272 .0778774 .000971
.0049984
---------+--------------------------------------------------------------------
combined | 12461 .0079181 .0007462 .0832931 .0064555
.0093807
---------+--------------------------------------------------------------------
diff | .0091577 .0014946 .006228
.0120874
------------------------------------------------------------------------------
diff = mean(0) - mean(1) t =
6.1271
Ho: diff = 0 degrees of freedom =
12459

Ha: diff < 0 Ha: diff != 0 Ha: diff > 0
Pr(T < t) = 1.0000 Pr(|T| > |t|) = 0.0000 Pr(T > t) = 0.0000

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfeeŽ Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

*
* 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/
```
Fred Wolfe
National Data Bank for Rheumatic Diseases
Wichita, Kansas
Tel +1 316 263 2125
fwolfe@arthritis-research.org

*
*   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/
```