| ![]() |
From | "Michael Blasnik" <michael.blasnik@verizon.net> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | st: Re: Foreach?? |
Date | Mon, 23 Oct 2006 18:09:20 -0400 |
I have 12 variables I7-Q7. I would like to run the following code for each variable in the varlist and save the result d1, d2, ..., d12. However, it appears that the macro i is not being incremented. Does any body know why? My thought is each time foreach loops over a variable the macro i should be incremented. foreach var of varlist I7-Q7 { use edata, clear keep if `var' == 1 bysort id (dov): gen etime = dov - dov[_n-1] keep if etime > 14 drop etime local i = 1 save d`i', replace local ++i }
* * 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–2025 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |