Statalist


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

Re: st: advance a -foreach- loop?


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: advance a -foreach- loop?
Date   Wed, 14 May 2008 14:34:58 -0400

Austin Nichols wrote:
The reason for moving the groups of variables into a separate macro
and dealing with the groups in a separate loop is: suppose for any
given variable v, you can identify a group of 6 related variables m_v
(including v itself) and process all 6 inside the loop.  When you
reach the next variable in group m_v, you will repeat this process,
making the whole thing take 6 times as long as it should.  OTOH, the
construction of a long local macro containing groups should take a
negligible amount of time, and then the groups can be looped over one
by one.


This is the root of my question - I want to advance the -foreach- loop
past the 6 variables. I tried -drop-ing the 6 but then the -foreach-
loop chokes.

I'm not concerned about the processing time; I want to group those 6
into a single table that is output into a report, and if I can't skip
them, I end up printing the same table 6 times.

I think the best solution may be the one suggested by Joseph Coveney,
to use a -while- loop, which lets me advance over the 6 with -gettoken-.

cheers,
Jeph

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