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 <pschumm@uchicago.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: looping over parallel lists - is there a alternative to "for"?
Date   Thu, 16 Mar 2006 15:11:22 -0600

On Mar 16, 2006, at 12:13 PM, Nick Cox wrote:

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.

Ah yes, very nice. It had never occurred to me to use -args- in this way (i.e., after a manual call to -tokenize- as opposed to the automatic tokenization of command line arguments). I retract my earlier suggestion, and thank you for the tip.


-- 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–2020 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index