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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

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: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Miranda Kim Gesendet: Donnerstag, 1. Oktober 2009 11:33 An: statalist@hsphsun2.harvard.edu 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/

**References**:**st: help with displaying appropriately formatted regression coefficients and p-values***From:*Miranda Kim <mk@mrc.soton.ac.uk>

- Prev by Date:
**Re: AW: st: AW: Keeping trailing zeros when formatting a decimal** - Next by Date:
**Re: st: Testing Linear Trade offs** - Previous by thread:
**st: help with displaying appropriately formatted regression coefficients and p-values** - Next by thread:
**RE: st: help with displaying appropriately formatted regression coefficients and p-values** - Index(es):

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