Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

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


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: looping over parallel lists - is there a alternative to "for"?
Date   Thu, 16 Mar 2006 12:06:56 -0600

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/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index