Hi, everyone,
I have an excel spreadsheet with World Bank development indicators for the years 2003-2013. I'd like to create a loop that exports a separate spreadsheet for each year.
Here is a sample of my data:
This is my code:
I am currently getting a "type mismatch" error code r(109), but I'm not sure why.
The year variable in my spreadsheet is an integer, so perhaps I messed up the syntax and the loop is expecting a string?
I have an excel spreadsheet with World Bank development indicators for the years 2003-2013. I'd like to create a loop that exports a separate spreadsheet for each year.
Here is a sample of my data:
Code:
input int year str52 reporterdesc str3 reporteriso str17(gdp_pc manuf industry) 2003 "Afghanistan" "AFG" "200.462375926026" "768258326.019014" "1030958898.99678" 2003 "Albania" "ALB" "1846.12012081207" "231427088.171808" "1349879571.14245" 2003 "Algeria" "DZA" "2117.04822899287" "27868320908.4311" "33920483855.7025" 2003 "American Samoa" "ASM" "9043.682366545279" "108000000" ".." 2003 "Andorra" "AND" "31954.1556558944" "85391740.59167489" "365933968.43826"
Code:
* Import excel file import excel using "intermediate_data/wb_dev_indic.xlsx", firstrow * Create local macros for each year local yr "03 04 05 06 07 08 09 10 11 12 13" * Loop through each year and export a separate spreadsheet foreach i in `yr' { export excel using "intermediate_data/wb_`yr'.xlsx" if year=="20`yr'", replace }
The year variable in my spreadsheet is an integer, so perhaps I messed up the syntax and the loop is expecting a string?
Comment