Statalist


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

Re: st: Table output


From   "Alan Neustadtl" <[email protected]>
To   [email protected]
Subject   Re: st: Table output
Date   Tue, 10 Jul 2007 16:31:59 -0400

Enclose your code in a "quietly block" and then display "noisily":

quietly (
  code goes here
  noisily di "***WHAT TO DISPLAY GOES HERE ***"
}

Best,
Alan





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/



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