Tuesday, March 07, 2006

st: RE: forvalues gives "numlist has too many elements" error

I can't reproduce this as a problem with -forval-.

Much of the point of -forval- is that it doesn't construct a numlist. (By the way, it will not accept numlists in general.) If it did, there would be no rationale for it as a separate command. Rather, it constructs its counter on the fly, so enabling speed and storage gains over the equivalent -foreach-.

On a separate detail, using -nullmat()- would enable you to remove the -if/else- branch.

How are you assigning to local macro 1?

Nick n.j.cox@durham.ac.uk

Pablo Mitnik > The code below worked fine, until I tried it with `1'==10000 > (`1' refers > to the number of repetitions in a simulation). > When I did this, I received the following error message: > > "invalid numlist has too many elements > r(123);" > > The help info on r(123) didn't help me -- it refers you to [U] 11.1.8 > numlist, but I didn't find anything > useful for my problem there. > > Any thoughts? Is there a workaround this issue? > -----------code begins-------------- > foreach posed in o2 o3 o4 b2 b3 b4 { > > forvalues rep = 1/`1' { > > if (`rep'==1) { > mat MR`posed'=(mr`posed'_`rep') > } > > else { > mat MR`posed'=(MR`posed' \ mr`posed'_`rep') > } > > } > } > -------------- code ends-------------------

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


Links to this post:

Create a Link

<< Home

This page is powered by Blogger. Isn't yours?