My data is in .xls format with multiple worksheets. The worksheets are named by stated (for example, California, Arizona, Texas...). I realize that the import excel command would basically import just the specified worksheet or the first worksheet by default. I have the option of using the xls2dta command that converts each worksheet into dta and then I append each file individually.
However, I am trying to append all the worksheets into a single excel file using a local macro.
I have the following command:
local mylist "California" "Texas" "Arizona"
foreach x in local `mylist' {
import excel using "C:\Users\Originaldata.xls", sheet("x") firstrow case(lower) clear
save "Originaldata", replace
}
I keep getting an error message that worksheet "x" cannot be found. I would really appreciate any help or ideas on how I could do this. I use Stata 13.
Thank you!!
Debbie
However, I am trying to append all the worksheets into a single excel file using a local macro.
I have the following command:
local mylist "California" "Texas" "Arizona"
foreach x in local `mylist' {
import excel using "C:\Users\Originaldata.xls", sheet("x") firstrow case(lower) clear
save "Originaldata", replace
}
I keep getting an error message that worksheet "x" cannot be found. I would really appreciate any help or ideas on how I could do this. I use Stata 13.
Thank you!!
Debbie
Comment