Suppose I am running a foreach loop in Stata, generally like
For some units, this "something" runs fast, but for others, it is taking too long.
I would like to tell Stata to ignore steps that are taking too long based on some time cutoff.
For example, suppose we have four units A, B, C and D to loop over. Unit A runs in one minute, unit B runs in three minutes, unit C takes half an hour and unit D runs in two minutes. But I don't have that information before running.
I would like to impose a cutoff like 10 minutes for example, so that A and B would run normally and C would be running for 10 minutes and then would break, and the loop would jump to D, that would also run normally.
Is there a way to do that in Stata?
Code:
foreach unit in units { do something }
I would like to tell Stata to ignore steps that are taking too long based on some time cutoff.
For example, suppose we have four units A, B, C and D to loop over. Unit A runs in one minute, unit B runs in three minutes, unit C takes half an hour and unit D runs in two minutes. But I don't have that information before running.
I would like to impose a cutoff like 10 minutes for example, so that A and B would run normally and C would be running for 10 minutes and then would break, and the loop would jump to D, that would also run normally.
Is there a way to do that in Stata?
Comment