> -----Original Message-----
> From: Euler P. G. de Mello [mailto:[email protected]]
> Sent: Tuesday, April 08, 2003 1:38 PM
> To: [email protected]
> Subject: st: numlist maximum capacity
>
>
> Dear Statalisters,
> I am trying to loop over 1870 cases using the -foreach-
> function, e.g.:
>
> . foreach n of numlist 1/1870{ display(`n')}
> invalid numlist has too many elements
> r(123);
>
> Does anybody know what's the maximum number of elements of a
> -numlist-?
> Thanks beforehand for the attention,
> Euler P.G de Mello
> [stata 7.0, win 98]
>
> Ps.:
> I have already managed to circunvene this situation by using
> something like:
>
> local step=0
> foreach n of numlist 1/2 {
> foreach m of numlist 1/5 {
> display(5*`step'+`m')
> }
> local step=`step'+1
>
> }
>
For the limits, type
. help limits
As it happens, the limit for numlists is 1600 elements. Whether or not
you are over that limit, it would be more efficient to code:
forvalues n=1/1870 {
<<do something>>>
}
If you need a numlist that does not increment by one, then you could do
something like:
local n 0
while `n'<10000 {
<<do something>>
local n=`n'+2
}
This would give you the numbers 0 through 10000 in steps of two, or the
equivalent of 0(2)10000.
Nick Winter
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/