Hello. When I run the first bit of code below (Stata/MP 15.1), the data imports properly:
However, when I run the code below I get the statement "January not found r(111)."
Moreover, if I drop January in the list, I get a different statement "worksheet February 2018 not found r(601)."
Why do the error statements differ and, in any case, what can I do to fix this loop? Thanks for any suggestions. I fear I'm missing something obvious.
Code:
import excel "C:\Users\Doug Hess\Downloads\dhs_nvra1.xlsx", sheet("January 2018") firstrow
Code:
foreach month in January February March April May June July August September October November December { clear import excel "C:\Users\Doug Hess\Downloads\dhs_nvra.xlsx", sheet("`month' 2018") firstrow gen year=2018 gen month=`month' save "D:\Data\State Data\Iowa\Iowa DHS `month' 2018.dta", replace }
Why do the error statements differ and, in any case, what can I do to fix this loop? Thanks for any suggestions. I fear I'm missing something obvious.
Comment