Stata Tip 85: Looping over Nonintegers
暂无分享,去创建一个
A loop over integers is the most common kind of loop over numbers in Stata programming, as indeed in programming generally. forvalues, foreach, and while may be used for such loops. See their manual entries in the Programming Reference Manual for more details if desired. Cox (2002) gives a basic tutorial on forvalues and foreach. In this tip, I will focus on forvalues, but the main message here applies also to the other constructs. Sometimes users want to loop over nonintegers. The help for forvalues contains an example:
[1] Nicholas J. Cox. Stata Tip 33: Sweet Sixteen: Hexadecimal Formats and Precision Problems , 2006 .
[2] Jean Marie Linhart,et al. Mata Matters: Overflow, Underflow and the IEEE Floating-Point Format , 2008 .
[3] William Gould. Mata Matters: Precision , 2006 .
[4] Nicholas J. Cox,et al. Speaking Stata: How to Face Lists with Fortitude , 2002 .