Hi Everyone,
So I am running a simulation study with a lot of different factors to look at, which means we end up with a lot of loops.
Each program runs independently without issue.
The simulation itself will run without issue for quite a while (around 2 hrs which saves around 11,000 results) and will trip over at a different point each time.
I can't give you the exact code just because the program is quite large, but a simplification that I think will highlight the problem is as below:
Now I realise no one would ever want to do the above, however it highlights the main issue. I have minimised the number of replace saves the program does as I was finding that the error would be read write access which I think was caused by the size of the dataset, meaning Stata hadn't quite done saving before it was trying to overwrite on the next loop. The final results are now being saved line by line to combat this problem. However, due to the program I am using, that merge step is unavoidable meaning at a point the program will trip when trying to save this temporary file.
Short of labelling every single temp file separately so that there can't be a read write issue, I have reached the point that I am out of ideas for how to get this thing to run through.
Any advice would be appreciated either on how I can stop Stata tripping over read write access, or on how to go about restarting at the point of tripping (I am saving the state in each results dataset with the thought this could be used to "pick up where I left off"?)
Thanks and best wishes,
Cydney
So I am running a simulation study with a lot of different factors to look at, which means we end up with a lot of loops.
Each program runs independently without issue.
The simulation itself will run without issue for quite a while (around 2 hrs which saves around 11,000 results) and will trip over at a different point each time.
I can't give you the exact code just because the program is quite large, but a simplification that I think will highlight the problem is as below:
Code:
foreach i of numlist 142 142.5 143 143.5 144 144.5 145 145.5 { foreach j of numlist 146 146.5 147 147.5 148 148.5 149 { foreach k of numlist 30 31 32 33 34 { foreach l of numlist 35 36 37 38 { forvalues m = 1/10 { clear sysuse surface.dta keep if `i' < latitude & latitude < `j' local n = _n gen ref = _n save temp.dta, replace clear set obs `n' gen ref = _n merge 1:1 ref using temp.dta keep if `k' < longitude & longitude < `l' gen closestate = c(seed) save "results_`i'_`j'_`k'_`l'_`m'.dta" } } } } }
Short of labelling every single temp file separately so that there can't be a read write issue, I have reached the point that I am out of ideas for how to get this thing to run through.
Any advice would be appreciated either on how I can stop Stata tripping over read write access, or on how to go about restarting at the point of tripping (I am saving the state in each results dataset with the thought this could be used to "pick up where I left off"?)
Thanks and best wishes,
Cydney
Comment