Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: simulataneous foreach loops


From   "Lim, Raymond" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: simulataneous foreach loops
Date   Fri, 12 Nov 2010 14:45:36 -0500

Austin, 
I preserve before the loop in my actual code. The loop right now creates team 101 with 3 members, team 102 with 5 members, team 103 with 3 members, etc. Yes, there's a one-to-one mapping from tt to NN. I basically need two loop indices to change simultaneously. For example, first round (i=103, j=3), second round (i=139, j=5), third round (i=230, j=3). Of course, the real thing is a couple hundred pairs. 

-Raymond

preserve
local tt=100
qui foreach NN of numlist 3 5 3 4 {
       bsample `NN'
       local tt=`tt'+1
       replace team=`tt'
       save simteam_`tt'.dta, replace
       restore
       preserve
       }

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index