Hi all,
I am unable to run a 'forvalues' command, and I am unsure as to why I am receiving the error "Operation timed Out".
Please see the code I am running below.
In sum, I am trying to loop over a large number of files in a folder (approx. 2000 files). I have limited the number of values to '5' to be able to test my code. However, once the code works, I will change the '5' to '2000' in the forvalues loop.
**** Stat Code ****
* save a copy so that we can load each observation in the loop below
tempfile files
save "files", replace
* loop over each file and input each csv file into temporary datasets.
forvalues i = 1/5 {
use "files" in `i', clear
global f = dirname + "/" + filename
global d = filename
clear
import delimited using "$f", varnames(1) numericcols(_all)
gen temp_cel = ((temp-32)*5)/9
gen dewp_cel = ((dewp-32)*5)/9
gen RH = (exp(17.625*(dewp_cel/(dewp_cel/(243.04+dewp_cel)))))/(exp(17.625*(temp_cel/(temp_cel/(243.04+temp_cel)))))
keep(date latitude longitude wdsp temp prcp RH)
save "$path/Data/dta_Temperature_df1/$d.dta", replace
}
**** end of state code ****
Thanks!
I am unable to run a 'forvalues' command, and I am unsure as to why I am receiving the error "Operation timed Out".
Please see the code I am running below.
In sum, I am trying to loop over a large number of files in a folder (approx. 2000 files). I have limited the number of values to '5' to be able to test my code. However, once the code works, I will change the '5' to '2000' in the forvalues loop.
**** Stat Code ****
* save a copy so that we can load each observation in the loop below
tempfile files
save "files", replace
* loop over each file and input each csv file into temporary datasets.
forvalues i = 1/5 {
use "files" in `i', clear
global f = dirname + "/" + filename
global d = filename
clear
import delimited using "$f", varnames(1) numericcols(_all)
gen temp_cel = ((temp-32)*5)/9
gen dewp_cel = ((dewp-32)*5)/9
gen RH = (exp(17.625*(dewp_cel/(dewp_cel/(243.04+dewp_cel)))))/(exp(17.625*(temp_cel/(temp_cel/(243.04+temp_cel)))))
keep(date latitude longitude wdsp temp prcp RH)
save "$path/Data/dta_Temperature_df1/$d.dta", replace
}
**** end of state code ****
Thanks!
Comment