Hi!
I want to import Excels files in a loop where the names include zeros. However, STATA ignores the zeros and reports that the Excel files cannot be found.
The Excel files are called: P+091231.xls, P+101231.xls etc. (located in the folder raw).
This is my code:
Is it possible to solve this without having to change the names of the original Excel files?
Thank you very much for you help!
/Louise
I want to import Excels files in a loop where the names include zeros. However, STATA ignores the zeros and reports that the Excel files cannot be found.
The Excel files are called: P+091231.xls, P+101231.xls etc. (located in the folder raw).
This is my code:
forvalues j=09(1)12{Error message: file raw/P+91231.xls not found. (So here STATA has searched for the file ...9... instead of ...09...)
import excel "raw\P+`j'1231.xls", sheet("A") firstrow clear
save "temp\P_20`j'12.dta", replace
clear
}
Is it possible to solve this without having to change the names of the original Excel files?
Thank you very much for you help!
/Louise
Comment