Dear statalist forum,
I am here because I am trying to conduct one task over several excel files located inside one folder and save the resulting data as new excel files in another folder .
But I keep receiving an error "Sensitivity not found" (or sometimes one of the other variables that I am using in the calculation), and I don't understand what has happened.
If anyone can shed light on my issue, I am truly grateful!
Imagine you have several different excel files inside folder "test" with context similar to:
The code I am trying to run, to open each *.xlsx file inside the folder "test" (global TEST "Path/test") is:
Output:
If you have any idea at all I would greatly appreciate it!!!
Thanks a lot.
I am here because I am trying to conduct one task over several excel files located inside one folder and save the resulting data as new excel files in another folder .
But I keep receiving an error "Sensitivity not found" (or sometimes one of the other variables that I am using in the calculation), and I don't understand what has happened.
If anyone can shed light on my issue, I am truly grateful!
Imagine you have several different excel files inside folder "test" with context similar to:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte id float Sensitivity int totalincludedparticipants 1 83 35 2 71 43 3 50 200 end
The code I am trying to run, to open each *.xlsx file inside the folder "test" (global TEST "Path/test") is:
Code:
cd $TEST set trace on global filenames : dir . files "*.xlsx" foreach filename in $filenames { di "`filename'" *Calculate our variables: * 1)Sensitivity with 95% CI *first we convert Sensitivity back to fraction gen sens=Sensitivity/100 gen SE_sens=sqrt(sens-(1-sens))/totalincludedparticipants //Im unsure if the SQRT should imnclude totalincludedparticipants or not? gen sens_up= sens + 1.96*SE_sens gen sens_low= sens - 1.96*SE_sens drop SE_sens *To save everything inside datatable as a new excelFile: export excel using "$EXPORT/new_`filename'", firstrow(variables) replace clear }
- foreach filename in $filenames { = foreach filename in "Book1.xlsx" "Book2.xlsx" { - di "`filename'" = di "Book1.xlsx" Book1.xlsx - gen sens=Sensitivity/100 Sensitivity not found gen SE_sens=sqrt(sens-(1-sens))/totalincludedparticipants gen sens_up= sens + 1.96*SE_sens gen sens_low= sens - 1.96*SE_sens drop SE_sens drop sens export excel using "$EXPORT/`filename'.xlsx", firstrow(variables) replace } r(111); |
If you have any idea at all I would greatly appreciate it!!!
Thanks a lot.
Comment