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

Re: st: -Table- output presented horizontally and exported


From   "Herve STOLOWY" <[email protected]>
To   <[email protected]>
Subject   Re: st: -Table- output presented horizontally and exported
Date   Thu, 03 Nov 2005 16:13:12 +0100

Dear Jean:

Thanks a lot for your help. I tried your solution and it works perfectly. 

May I add a related question: is there a way to use the same technique to get for each variable the total number of observations (see below):

                yes     no       N
dummy1   12      43       55
dummy2   29      19       48

Best regards

Herv�



***********************************************************
Professeur/Professor
Coordinateur du D�partement/Head of Department
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
[email protected]
http://campus.hec.fr/profs/stolowy/perso/home.htm
>>> [email protected] 11/03/05 3:43 PM >>>
Herv�,

If I understand you correctly, you want to obtain a tab-delimited file 
that should look like the following:

                 yes     no
dummy1   12      43
dummy2   29      19
...

If yes, here is one solution that works for me. It is based on the 
-file- command, and will write the results into a file called 
"DummyTable.txt"

file open dum using DummyTable.txt, write text replace
file write dum _tab "yes" _tab "no" _n
foreach v of varlist dummy* {
    file write dum "`v'" _tab
    count if `v' == 0
    file write dum (r(N)) _tab
    count if `v' == 1
    file write dum (r(N)) _n
}
file close dum
type DummyTable.txt


I hope this helps,

jean

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



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