Hello,
I'm trying to apply the following commands to ten hospital datasets using the local filelist command. My code is as follows:
-----------------------------------------------------------------------------------------------------
local filelist: dir"/Users/CDDEP/Downloads" files"*.dta"
foreach file of local filelist {
gen double dateofadmission_rc = clock(dateofadmission, "DMY")
format dateofadmission_rc %tcCCYY-NN-DD_HH:MM:SS
gen double dateofdischarge_rc = clock(dateofdischarge, "DMY")
format dateofdischarge_rc %tcCCYY-NN-DD_HH:MM:SS
gen double reportdate_rc = clock(reportdate, "DMY")
format reportdate_rc %tcCCYY-NN-DD_HH:MM:SS
gen mortality_rc="false"
replace mortality_rc="true" if mortality=="Yes"
label variable mortality_rc "Mortality"
gen double dateofdeath_rc = clock(dateofdischarge, "DMY") if mortality_rc=="true"
format dateofdeath_rc %tcCCYY-NN-DD_HH:MM:SS
save "/Users/CDDEP/Documents/RESMAP/Fortis/`file'", replace
clear
}
---------------------------------------------------------------------------------------------------------
However, the following error comes up after only one iteration:
"dateofadmission not found r(111)"
I've visited other threads, but can't seem to figure it out. Any advice would be appreciated.
Thank you,
Katie
I'm trying to apply the following commands to ten hospital datasets using the local filelist command. My code is as follows:
-----------------------------------------------------------------------------------------------------
local filelist: dir"/Users/CDDEP/Downloads" files"*.dta"
foreach file of local filelist {
gen double dateofadmission_rc = clock(dateofadmission, "DMY")
format dateofadmission_rc %tcCCYY-NN-DD_HH:MM:SS
gen double dateofdischarge_rc = clock(dateofdischarge, "DMY")
format dateofdischarge_rc %tcCCYY-NN-DD_HH:MM:SS
gen double reportdate_rc = clock(reportdate, "DMY")
format reportdate_rc %tcCCYY-NN-DD_HH:MM:SS
gen mortality_rc="false"
replace mortality_rc="true" if mortality=="Yes"
label variable mortality_rc "Mortality"
gen double dateofdeath_rc = clock(dateofdischarge, "DMY") if mortality_rc=="true"
format dateofdeath_rc %tcCCYY-NN-DD_HH:MM:SS
save "/Users/CDDEP/Documents/RESMAP/Fortis/`file'", replace
clear
}
---------------------------------------------------------------------------------------------------------
However, the following error comes up after only one iteration:
"dateofadmission not found r(111)"
I've visited other threads, but can't seem to figure it out. Any advice would be appreciated.
Thank you,
Katie
Comment