local x : env SGE_TASK_ID log using "mystata_log_`x'.log", replace display "My task ID is `x'" local i1 = (`x'-1)*10 +1 local i2 = `x'*10 * The largest value of the loop is 37 if `i2' > 37{ i2=37 } * i2 = min(`i2', 37) forvalues i=`i1'/`i2'{ display " My iteration is `i'" } log close