Statalist


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

st: AW: RE: AW: forvalues i = 0(.05).15


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: RE: AW: forvalues i = 0(.05).15
Date   Mon, 9 Nov 2009 21:44:38 +0100

<> 



This behavior is intentional, though: The step size for this particular
syntax is the difference between the first and the second argument, i.e.
31.6-31.3=0.3, so it cannot hit the 38 exactly and stops short of it. To get
an exact hit, increase the upper bound to 38.2...


*************
forval x = 31.3 31.6 : 38.2 {
                di `x'
          }
*************


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von David Airey
Gesendet: Montag, 9. November 2009 21:07
An: Statalist
Betreff: st: RE: AW: forvalues i = 0(.05).15

.


>
> -help forvalues- should probably carry a warning regarding the hazard
> highlighted by David, particularly given the fact that it advocates  
> "...a
> loop over noninteger values" in its last example...
>
>
>
> HTH
> Martin

True, especially because the issue that bit me bit Stata: see the  
output misses 38! See below.

Thanks Nick and Martin.

-Dave

> . forvalues x = 31.3 31.6:38 {
>   2. display `x'
>   3. }
> 31.3
> 31.6
> 31.9
> 32.2
> 32.5
> 32.8
> 33.1
> 33.4
> 33.7
> 34
> 34.3
> 34.6
> 34.9
> 35.2
> 35.5
> 35.8
> 36.1
> 36.4
> 36.7
> 37
> 37.3
> 37.6
> 37.9
>

*
*   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