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
}
Raphael
*
* 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/