Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: help with displaying appropriately formatted regression coefficients and p-values
Date   Thu, 1 Oct 2009 15:14:09 +0200

<> 

-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: [email protected]
[mailto:[email protected]] Im Auftrag von Miranda Kim
Gesendet: Donnerstag, 1. Oktober 2009 11:33
An: [email protected]
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/



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