# Rép. : st: RE: formatting and exporting ttest results

 From "Herve STOLOWY" To Subject Rép. : st: RE: formatting and exporting ttest results Date Wed, 12 Apr 2006 17:01:50 +0200

```Dear Ina:

Sorry, I did not see your first posting. I just discovered Nick's reply. Some time ago, I raised the same issue and received several replies which helped to find a solution. But this solution, as Nick said, is not a "short answer".

If you make a ttest with a groupvar, you can use -statsmat- and -makematrix- (downloadable from ssc)(with -ttest-) followed by -mat2txt- (downloadable from ssc) to get a .txt file.

Here is an example I used for one research project:

statsmat size1, s(N mean sd) by(format_bs) mat(mat1)
makematrix mat2, from(r(t) r(p)) label : ttest size1, by(format_bs)
matrix mat3=mat2' //Transposition of the matrix
matrix mat4 = mat1, mat3 // Grouping of the two matrices
matrix colnames mat4 = "Number of observations" Mean "Standard deviation" "Student t-test"
mat2txt, matrix(mat4) saving(univariate_bs) replace

If you want to compare two variables with a ttest, here is another example and solution:

makematrix T5A1, from(r(N) r(mean) r(sd) r(min) r(p50) r(max)) label : univar MAPE_direct_scal MAPE_indirect_scal if outlier_cfo_scal!=1 &outlier_MAPE!=1
ttest MAPE_direct_scal = MAPE_indirect_scal if outlier_cfo_scal!=1 &outlier_MAPE!=1
mat T5A2 = r(p) \ r(t)
mat T5A3 = T5A1, T5A2
matrix colnames T5A3 = N "Mean" "Std Dev" "Min" "Median"  "Max" "T/p-value"
mat2txt, matrix(T5A3) saving(stat_MAPE_table5A)  replace

The syntax might not the most effective but I know these commands work.

I hope this helps.

Best regards

Hervé Stolowy
***********************************************************
Professeur/Professor
HEC Paris
Département Comptabilité Contrôle de gestion / Dept of Accounting and Management Control
1, rue de la Liberation
78351 - Jouy-en-Josas
France
Tel: +33 1 39 67 94 42 - Fax: +33 1 39 67 70 86
stolowy@hec.fr
http://studies.hec.fr/web/stolowy
>>> n.j.cox@durham.ac.uk 12/04/06 13:50 >>>
The short answer is: Evidently not.

However, as a t-test comparing two group means
is really a regression in disguise, you
should be able to use your favourite post-regression
program for this purpose.

Nick
n.j.cox@durham.ac.uk

Ina Ganguli

> I was wondering whether there is a command (like -outreg-) I can use
> to format and export multiple -ttest- results to a .txt file for
> easier conversion to tables?
>
> I would like to have results in the following format:
>
>                     Group1     Group2     Difference
> variable1       mean       mean        mean*
>                       (se)          (se)          (se)
> variable2       mean       mean        mean*
>                       (se)          (se)          (se)
> etc.
>
> I've seen references to commands that may perhaps be what I need
> (-tabexport-, -parmby-?), but I wanted to check whether there is a
> program/command out there that would work well for this.

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

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