Dear Stata lister,
I have a small problem with a nested loop and maybe you can give me an advice. For a specific business starting activity I have data for the beginning (BUSINESSPLAN_SP[odd]) and the end (BUSINESSPLAN_SP[even]) of this activity. For instance the entrepreneur worked on the business plan in the months 4 till 7 as well as 16 till 25. I want to transfer the information into a time grid. In this grid t1, t2, etc. stands for the respective month. They should take the value of 1 if the entrepreneur worked on the business plan on the point of time. I have here a first draft of the loop.
set more off
local r=5
forvalues i=1/100 {
local j=1
local k=`j'+1
while `j'<=`r' {
replace t`i' = 1 BUSINESSPLAN_SP`j'<=`i' & BUSINESSPLAN_SP`k'>=`i'
local j=`j'+1
}
}
The problem is that this loop recognizes the first sequence (4 to 7), but not the second sequence (16 to 25). I suspect something is wrong with the resetting of the local j (local j=`j'+1) and k.
Thanks for your help
Michael
*
* 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/