# Example of restartable bootstrap. It runs 10 # separate bootstraps, and then combines the # results in file1.dta...file10.dta. If the job # is interrupted only the file in progress needs # to be recomputed. The files that can be skipped # are noted by the -confirm file- command. # Saving to tmp, then copying to another location # makes the individual groups atomic. # The -in 1/L- qualifier is necessary. log using bs,text replace set rmsg on set processors 4 set more off set obs 100000 gen x = uniform() gen y = uniform() + x forvalues i=1/10 { capture confirm file file`i'.dta if _rc == 0 { di "skip `i' } else { set seed 1234`i'56 di "do " `i' quietly bootstrap, reps(50) saving(tmp,replace): reg y x shell mv tmp.dta file`i'.dta } } clear forvalues i=1/10 { append using file`i' } bstat in 1/L