Playing aside, my advice is never to work with a -forval- loop over
non-integers.
forval i = 0/6 {
di 0.025 * `i'
}
is immensely preferable to
forval i = 0(0.025)0.15 {
di `i'
}
Precision is not the only issue. It is easier to write clear and correct
code the first way than the second.
Nick
[email protected]
Martin Weiss
Big fun to play around with this:
*************
forv i = 0(.025)0.15 {
di in r `i' _col(10) float(`i')
}
forv i = 0(.005)0.15 {
di in r `i' _col(10) float(`i')
}
*************
Probably related to the issues in [U], 13.11., and Nick`s SJ tip
http://www.stata-journal.com/sjpdf.html?articlenum=dm0022
David Airey
The fact that forvalues
forvalues i = (0)(.05).15 {
display `i'
}
gives
. forvalues i = 0(.05).15 {
2. display `i'
3. }
0
.05
.1
is related to accuracy of a macro or float right (.15 is missing)?
I could alternatively type:
forvalues i = 0(5)15 {
display `i'/10
}
or
forvalues i = 0(.05).16 {
display `i'
}
*
* 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/