I have a bunch of variables and I want to conduct a 2-group mean comparison test with unequal variances for each of the variables. As an example, I used the the quantitative variable Words, which is divided into two groups as follows: Verified = 1 i.e. true, and, Verified = 0 i.e. False.

I want to export the Means, the diff, the t-value and the p-value (in blue font below). While the t-value and the p-value is in the stored results, the Means of each group are not stored. Neither is the diff. What is the best way to export the Means, the diff, the t-value and the p-value into an excel file all at once for each variable?

I would be very grateful for help with the code.

Here is my output:

ttest Words , by( Verified ) unequal
Two-sample t test with unequal variances
------------------------------------------------------------------------------
Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval]
---------+--------------------------------------------------------------------
0_False | 1,002 23379.45 633.5608 20054.98 22136.19 24622.71
1_True | 231 37194.2 1526.441 23199.9 34186.6 40201.79
---------+--------------------------------------------------------------------
combined | 1,233 25967.61 608.3704 21362.38 24774.05 27161.17
---------+--------------------------------------------------------------------
diff | -13814.75 1652.701 -17066.52 -10562.98
------------------------------------------------------------------------------
diff = mean(0_False) - mean(1_True) t = -8.3589
Ho: diff = 0 Satterthwaite's degrees of freedom = 313.931
Ha: diff < 0 Ha: diff != 0 Ha: diff > 0
Pr(T < t) = 0.0000 Pr(|T| > |t|) = 0.0000 Pr(T > t) = 1.0000

. return list
scalars:
r(level) = 95
r(sd) = 21362.37977652895
r(sd_2) = 23199.89565108091
r(sd_1) = 20054.97694223148
r(se) = 1652.701313459743
r(p_u) = .999999999999999
r(p_l) = 1.04042546660e-15
r(p) = 2.08085093319e-15
r(t) = -8.358892749649407
r(df_t) = 313.9306465933078
r(mu_2) = 37194.19913419913
r(N_2) = 231
r(mu_1) = 23379.44610778443
r(N_1) = 1002

. ereturn list
scalars:
e(g_avg) = 6.290816326530612
e(g_min) = 1
e(r2_w) = .0473434965397944
e(r2_o) = .4506131136165867
e(r2_b) = .5607902730496568
e(Tcon) = 0
e(Tbar) = 6.290816326530612
e(N) = 1233
e(N_g) = 196
e(rank) = 21
e(df_r) = 175
e(ll_0) = 31.27062242352715
e(ll) = 111.902890145359
e(r2_a) = .5105948756839033
e(rss) = 3.663325593087079
e(mss) = 4.677394951795689
e(rmse) = .1446834099105863
e(r2) = .5607902730496568
e(F) = 11.17214530574199
e(df_m) = 20
e(p) = 4.39187568586e-22
e(g_max) = 13

macros:
e(cmdline) : "xtreg Environmental Trend LnTotalAssets Intangibles MTB leverage Fir.."
e(title) : "Between regression (regression on group means)"
e(cmd) : "xtreg"
e(predict) : "xtrefe_p"
e(marginsnotok) : "E U UE SCore STDP XBU"
e(marginstok) : "XB default"
e(model) : "be"
e(ivar) : "CompName"
e(vce) : "conventional"
e(depvar) : "Environmental"
e(typ) : "WLS "
e(properties) : "b V"

matrices:
e(b) : 1 x 25
e(V) : 25 x 25

functions:
e(sample)



I tried asdoc, and, it seems to work only with equal variances. I got the following error message when used this command: asdoc ttest Words , by( Verified ) unequal replace

file Myfile.doc could not be opened
fopen(): 603 file could not be opened
asdoctable(): - function returned error
<istmt>: - function returned error
r(603);