// Download data
wbopendata, clear long year(1990:2014) indicator(sh.xpd.publ.zs)
rename sh_xpd_publ_zs spending
rename iso2code country
label var spending "Health expenditure, public (% of GDP)"
// Group countries
gen lac = (inlist(country, "AR", "BS", "BB", "BZ", "BO", "BR", "CL") ///
| inlist(country, "CO", "CR", "CU", "DO", "EC", "SV", "GT") ///
| inlist(country, "GY", "HT", "HN", "JM", "MX", "NI", "PA") ///
| inlist(country, "PY", "PE", "SR", "TT", "UY", "VE"))
gen oecd = (inlist(country, "AT", "AU", "BE", "CA", "CZ", "DK", "EE") ///
| inlist(country, "FI", "FR", "DE", "HU", "IS", "IE", "IT") ///
| inlist(country, "JP", "LU", "NL", "NZ", "NO", "PL", "PT") ///
| inlist(country, "SK", "SI", "ES", "SE", "CH", "GB", "US"))
generate group = ""
replace group = "OECD" if oecd
replace group = "LAC" if lac
// Drop other countries and old data
drop if group == ""
drop if year < 1995
// Drop unnecessary variables
drop countrycode region regioncode
drop lac oecd
// Calculate average spending
sort group year country
*list, sepby(year)
bysort group year: egen avgspending = mean(spending)
*list, sepby(year)
// Calculate coefficient of variation
sort group year country
*list, sepby(year)
bysort group year: egen sdspending = sd(spending)
*list, sepby(year)
gen cvspending = (sdspending/avgspending) * 100
*list, sepby(year) abb(20)
// Figure 1a
sort group year
twoway (line avgspending year if group == "OECD") ///
(line avgspending year if group == "LAC") ///
(line spending year if country == "NL"), ///
legend(order(1 "OECD regional average" 3 "The Netherlands" 2 "LAC regional average") title("") ring(0)) ///
yscale(range(0 10)) ylabel(0 (1) 10, grid) ytitle("Public health expenditure (% of GDP)") ///
xlabel(1995 2000 2005 2010 2014, tick) xmtick(1995/2014) xtitle("") name(figure1a, replace) ysize(4) nodraw
// Figure 1b
sort group year
twoway (line cvspending year if group == "OECD") ///
(line cvspending year if group == "LAC"), ///
legend(order(2 "LAC" 1 "OECD") title("Coefficient of Variation (CV)") ring(0)) ///
yscale(range(0 50)) ylabel(0 (5) 50, grid) ytitle("CV of public health expenditure") ///
xlabel(1995 2000 2005 2010 2014, tick) xmtick(1995/2014) xtitle("") name(figure2a, replace) ysize(4) nodraw
// Combined Figures
graph combine figure1a figure2a, col(1) ysize(8) name(figure1, replace)
Apr 28, 2016
Random graphs (77): Line plots
Labels:
bysort,
egen,
Random graphs,
twoway line,
wbopendata
