Dear Stata listers,
I have again a looping problem, and would be very thankful for a hint. I have a time grid t1, t2 ... till t146, representing the number of months since the start of the venture creation process of a company. In this time grid t has the value of 1 if the company worked on a specific activity in the venture creation process. If the company did not work on this activity t equals zero. There are 32 (j) such activities, and therefore for each company there are 32 rows in the dataset.
What I intend to do is to create a variable (timing_activities) which takes the value of the month in which for the first time the company has worked on this activity (e.g. 5 if the company worked in the 5th month for the first time on that activity). Obviously I need a more advanced loop for that job. It must loop over all 32 activities and over all months, while evaluating if the company for the first time worked on that activity j. Below is a first draft of such a loop, but unfortunately it produces only missings in the variable timing_activities.
forvalues j=1/32 {
local i=1
while `i'<=146 {
if t`i'==1 {
replace timing_activities=`i' if activity==`j'
local i=`i'+1
}
else {
local i=`i'+1
}
}
}
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/