Hello all:
I wrote this wrapper program to gather death rate from strate. Close to the conclusion of the program, the tempfile.dta is getting saved physically in the working directory and halting my do file from running further. This seems to be sporadic and I can't figure out how to fix the halt. I include my code and a portion where the error seems to be halting in the trace. I see that file in my pwd and deleted it too. But that seems to work only sometimes with clearing that file.If you have ideas for getting this right, I would like to know.
The program
Error with trace
I wrote this wrapper program to gather death rate from strate. Close to the conclusion of the program, the tempfile.dta is getting saved physically in the working directory and halting my do file from running further. This seems to be sporadic and I can't figure out how to fix the halt. I include my code and a portion where the error seems to be halting in the trace. I see that file in my pwd and deleted it too. But that seems to work only sometimes with clearing that file.If you have ideas for getting this right, I would like to know.
The program
Code:
*! program mrate v1.0.0 GV 9nov2023 cap program drop mrate return clear program define mrate, rclass version 18.0 syntax [varname(default=none)] [, CLUster(string)] cap assert !missing(_st) if c(rc){ di as error: "Data needs to be stset first" } * tabulate total deaths *---------------------- qui estpost tab _d return local dead = e(b)[1,2] qui strate, per(1000) `clu' output(tempfile, replace) tempname tfrm mkf `tfrm' frame `tfrm' { use tempfile local r = string(_Rate[1], "%09.1fc") ret local drate "death rate of `r' per 1000 patient-years" local d } ret li end
Error with trace
Code:
------------------------------------------------- end st_set.Clear ---
- exit
--------------------------------------------------------- end st_set ---
- exit
------------------------------------------------------------ end stset ---
- qui save `"`outnam'"', `outrepl'
= qui save `"tempfile"', replace
file tempfile.dta cannot be modified or erased; likely cause is read-only
directory or file
restore
}
}
- if "`jack'" !="" {
= if "" !="" {
return hidden scalar flag = `missflg'
return hidden local method "jackknife"
}
- local rc = _rc
- capture drop _D
- capture drop _E
- capture drop _SMR
- capture drop _Lower
- capture drop _Upper
- capture drop _Y
- capture drop _Rate
- capture drop _MY
- capture drop _NY
- exit `rc'
= exit 608
------------------------------------------------------------- end strate ---
---------------------------------------------------------------- end mrate ---
r(608);
end of do-file
r(608);
Comment