Thursday, March 16, 2006

Re: st: looping over parallel lists - is there a alternative to "for"?

On Mar 16, 2006, at 11:44 AM, Nick Cox wrote: > Also, you could -tokenize- inside the loop: > > foreach element of loc nylist { > tokenize `element' > ... > }

Indeed, this would make for much cleaner code within the loop, albeit still a bit difficult to read (since one has to go back and forth between the positional macros and what they refer to). For this reason, I still think it would be nifty if you could write:

loc mylist `" "1 a I" "2 b III" "3 c III" "' foreach numeral, letter, roman of loc mylist { ... }

but, as I said, I haven't thought through the full implications of this, nor do I have any idea how difficult it would be to implement. I also have no idea whether it would offend StataCorp from an aesthetic perspective...

-- Phil

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


Tag:


Links to this post:

Create a Link



<< Home

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