Thursday, March 16, 2006

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

I don't particularly yearn for that, nor I do argue against.

But what you can do now -- and indeed for some time past -- is not far away:

foreach element of loc mylist { tokenize `element' args numeral letter roman ... }

If there was a lot in the loop this would make code clearer.

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

Phil Schumm > 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...

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