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)
Scatter PlotWhat command can I use to create a Scatter plot with regression line and line of perfect correlation…
Store coefficients/SEs for factor variables, maybe using statsbyI'm regressing something on a factor variable with many levels. I would like to save the coefficient…
Making systematic changes to set of do-filesI have a large number of do-files that I would like to run by systematically changing parts of the c…
Moderator affected by IV, in Mediation Effect on DVMy model looks like this: IV ---> Mediator1 ----> DV and Moderator 1, Moderator 2, Moderator …
combining datasets where want to replace incorrect values of one variableIn my master dataset I have incorrect values of l for the years 1997-2000. I want to replace these v…
Subscribe to:
Post Comments (Atom)
0 Response to Sudden r(608) error in a loop (file cannot be modified)
Post a Comment