st: help with displaying appropriately formatted regression coefficients and p-values

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

st: help with displaying appropriately formatted regression coefficients and p-values

mk-6
I am trying to write a loop to format my regression coefficients and
p-values so that I have 2 significant figures for my p-values and a
reasonable format for the betas (these span considerably different
scales...). I want to do it in a loop as I have hundreds of these
coefficients and p-values.
I was thinking of some loop as follows, but foreach doesn't seem
appropriate here...
Any clues would be of great help!

foreach num of numlist 1.367456 0.0000925 0.5623 13.5678 {
    if `num' < 0 {    /* store number in macro as string rounded to two
significant figures */
    }
    if `num' > 1 {    /* store number in macro as string rounded to two
decimal places */
    }
}

I use Stata 10 btw.
Many thanks!


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|

st: AW: help with displaying appropriately formatted regression coefficients and p-values

Martin Weiss-5

<>

-foreach- is innocent, though. One of the problems is that you have not
covered the possibility that `num' is between 0 and 1, if only by including
an -else- branch...

I would look at -esttab- from ssc which lets you format results quite
comprehensively...


*************
foreach num of numlist 1.367456 0.0000925 0.5623 13.5678 {
    if `num' < 0 {
    di "significant figures"   /* store number in macro as string rounded to
two
significant figures */
    }
    if `num' > 1 {  
    di "decimal places"  /* store number in macro as string rounded to two
decimal places */
    }
}
*************



HTH
Martin


-----Urspr├╝ngliche Nachricht-----
Von: [hidden email]
[mailto:[hidden email]] Im Auftrag von Miranda Kim
Gesendet: Donnerstag, 1. Oktober 2009 11:33
An: [hidden email]
Betreff: st: help with displaying appropriately formatted regression
coefficients and p-values

I am trying to write a loop to format my regression coefficients and
p-values so that I have 2 significant figures for my p-values and a
reasonable format for the betas (these span considerably different
scales...). I want to do it in a loop as I have hundreds of these
coefficients and p-values.
I was thinking of some loop as follows, but foreach doesn't seem
appropriate here...
Any clues would be of great help!

foreach num of numlist 1.367456 0.0000925 0.5623 13.5678 {
    if `num' < 0 {    /* store number in macro as string rounded to two
significant figures */
    }
    if `num' > 1 {    /* store number in macro as string rounded to two
decimal places */
    }
}

I use Stata 10 btw.
Many thanks!


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|

RE: st: help with displaying appropriately formatted regression coefficients and p-values

Roy Wada
In reply to this post by mk-6
> foreach num of numlist 1.367456 0.0000925 0.5623 13.5678 {

autofmt, input(1.367456 0.0000925 0.5623 13.5678) auto(2)
ret list
 
. ret list
scalars:
             r(deci4) =  1
             r(deci3) =  2
             r(deci2) =  6
             r(deci1) =  2
macros:
           r(output4) : "13.6"
            r(input4) : "13.5678"
              r(fmt4) : "1f"
           r(output3) : "0.56"
            r(input3) : "0.5623"
              r(fmt3) : "2f"
           r(output2) : "0.000092"
            r(input2) : "0.0000925"
              r(fmt2) : "6f"
           r(output1) : "1.37"
            r(input1) : "1.367456"
              r(fmt1) : "2f"    
_________________________________________________________________
Insert movie times and more without leaving Hotmail®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/