Hello,
I have encountered a strange problem (at least for me). I run a loop of the following form to generate a distribution of adjusted R2s (can't use the bootstrap command for reasons irrelevant here):
clear
save "XY", replace emptyok
forvalues i = 1/1000 {
display `i'
use "XYZ" , clear
bsample 1000
quietly: reg xy
clear
save "helpfile", replace emptyok
set obs 1
gen ar2_xy =.
replace ar2_xy = e(r2_a)
save "helpfile", replace
use "XY", clear
append using "helpfile"
save "XY", replace
}
The code works in principle and sometimes runs through smoothly, but most times after a random number of iterations gives me:
(...)
109
(note: dataset contains 0 observations)
file helpfile.dta saved
number of observations (_N) was 0, now 1
(1 missing value generated)
(1 real change made)
file helpfile.dta saved
file XY.dta saved
110
(note: dataset contains 0 observations)
file helpfile.dta cannot be modified or erased; likely cause is read-only
directory or file
r(608);
end of do-file
Why would the file suddenly be read-only? And as I said, sometimes it does finish all 1000 iterations without error.
Thanks a lot for your help!
Ferdinand
Related Posts with Sudden r(608) error in a loop (file cannot be modified)
Find matched firmsHello everyone, Hope everything is going well. I have a question about how to identify the matched…
RecodingHello, I have the variable gender which was originally coded as 1 = male and 2 = female. I went in …
Backward Compatibility .mlib-s Complied in v17Hi All, Yesterday a user made an issue on the -domin- (SSC) package's GitHub page noting that they …
how to Import many excel files with multiple sheets and appending each sheet into one dta file for each file with the same excel file nameHello everyone, I just joined Statalist. So this is my first post. I would like to give you a brie…
Is there any way to stop pyStata while running?We know that both python and Stata have the stop-process capability, but it seems impossible to do t…
Subscribe to:
Post Comments (Atom)
0 Response to Sudden r(608) error in a loop (file cannot be modified)
Post a Comment