Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Table output


From   "Nuno" <[email protected]>
To   <[email protected]>
Subject   RE: st: Table output
Date   Tue, 10 Jul 2007 21:41:04 +0100

Thank you Carole and Alan!

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Carole J. Wilson
Sent: ter�a-feira, 10 de Julho de 2007 21:31
To: [email protected]
Subject: Re: st: Table output

How about:


qui{
noi di "Variable`=char(9)'Mean`=char(9)'p-value"
foreach var of varlist x1-x11 {
cap ttest `var'==0
noi di as text "`var'`=char(9)'" as result  %8.4f `r(mu_1)'
"`=char(9)'" %8.4f `r(p)'
}
}


_________________________________
       Carole J. Wilson
 University of Texas at Dallas
 School of Economic, Political,
      and Policy Sciences
      Phone: 972.883.4957
       Fax: 972.883.6571
     [email protected]
http://www.utdallas.edu/~cjwilson
__________________________________



On 7/10/07, Nuno <[email protected]> wrote:
> Hi everyone,
>
> I wanted to build a table that summarizes the output of several ttest 
> on different variables on a single table. To do this I've written a 
> small piece of code, that isn't displaying the table exactly as I
intended:
>
> di "Variable`=char(9)'Mean`=char(9)'p-value"
> foreach var of varlist x1-x11 {
> cap ttest `var'==0
> di as text "`var'`=char(9)'" as result  %8.4f `r(mu_1)' "`=char(9)'" 
> %8.4f `r(p)'
> }
>
> The output is the following:
>
> Variable       Mean    p-value
>
> . foreach var of varlist x1-x11 {
>  2. cap ttest `var'==0
>  3. di as text "`var'`=char(9)'" as result  %8.4f `r(mu_1)' "`=char(9)'"
> %8.4f `r(p)'
>  4. }
> x1    0.0926          0.1880
> x2    0.0502          0.1763
> x3   -0.0078          0.5102
> x4    0.0114          0.5810
> x5    0.0012          0.9515
> x6    0.0094          0.5713
> x7   -0.0199          0.1522
> x8   -0.0332          0.0668
> x9   -0.0255          0.1281
> x10  -0.0508          0.0051
> x11   0.1434          0.0529
>
> The desired output is:
> Variable       Mean    p-value
> x1    0.0926          0.1880
> x2    0.0502          0.1763
> x3   -0.0078          0.5102
> x4    0.0114          0.5810
> x5    0.0012          0.9515
> x6    0.0094          0.5713
> x7   -0.0199          0.1522
> x8   -0.0332          0.0668
> x9   -0.0255          0.1281
> x10  -0.0508          0.0051
> x11   0.1434          0.0529
>
> Is there a way for Stata not to display the foreach...
>
> Best,
>
> Nuno
>
> *
> *   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/


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