# Re: st: storing t value from a t-test

 From Richard Williams To statalist@hsphsun2.harvard.edu, Subject Re: st: storing t value from a t-test Date Sun, 04 May 2008 10:50:55 -0500

```At 09:34 AM 5/4/2008, Armelini, Guillermo wrote:
```
Hi everybody,

Does anyone who knows how can i store the T value of the T Test in a local macro?

Two-sample t test with equal variances
------------------------------------------------------------------------------
Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval]
---------+--------------------------------------------------------------------
1 | 77 3.402597 .0872214 .7653644 3.228881 3.576314
2 | 13 3.615385 .2129904 .7679476 3.151318 4.079451
---------+--------------------------------------------------------------------
combined | 90 3.433333 .0806497 .76511 3.273084 3.593583
---------+--------------------------------------------------------------------
diff | -.2127872 .2296004 -.6690697 .2434953
------------------------------------------------------------------------------
diff = mean(1) - mean(2) t = -0.9268
Ho: diff = 0 degrees of freedom = 88
Ha: diff < 0 Ha: diff != 0 Ha: diff > 0
Pr(T < t) = 0.1783 Pr(|T| > |t|) = 0.3566 Pr(T > t) = 0.8217

I would like to store t ( in this case -0.9268) and the p-value (in this case 0.1783)
```The information you want is stored in r, e.g.

. webuse auto
(1978 Automobile Data)

. ttest price, by(foreign)

Two-sample t test with equal variances
------------------------------------------------------------------------------
Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
Domestic |      52    6072.423    429.4911    3097.104    5210.184    6934.662
Foreign |      22    6384.682    558.9942    2621.915     5222.19    7547.174
---------+--------------------------------------------------------------------
combined |      74    6165.257    342.8719    2949.496    5481.914      6848.6
---------+--------------------------------------------------------------------
diff |           -312.2587    754.4488               -1816.225    1191.708
------------------------------------------------------------------------------
diff = mean(Domestic) - mean(Foreign)                         t =  -0.4139
Ho: diff = 0                                     degrees of freedom =       72

Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
Pr(T < t) = 0.3401         Pr(|T| > |t|) = 0.6802          Pr(T > t) = 0.6599

. return list

scalars:
r(sd) =  2949.49588476892
r(sd_2) =  2621.915083190759
r(sd_1) =  3097.104279086425
r(se) =  754.4488373823767
r(p_u) =  .6599074558726947
r(p_l) =  .3400925441273052
r(p) =  .6801850882546103
r(t) =  -.4138898832983144
r(df_t) =  72
r(mu_2) =  6384.681818181818
r(N_2) =  22
r(mu_1) =  6072.423076923077
r(N_1) =  52

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  Richard.A.Williams.5@ND.Edu
WWW:    http://www.nd.edu/~rwilliam

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