Jun 2, 2016

Random graphs (89): Bar graph

clear

// Read in data
import excel "http://hdr.undp.org/sites/default/files/composite_tables/2015_Statistical_Annex_Table_5.xls", ///
       sheet("Table 5") cellrange(B11:C188)

// Prepare country variables
rename B country
drop if country == "HIGH HUMAN DEVELOPMENT"
drop if country == "MEDIUM HUMAN DEVELOPMENT"
drop if country == "LOW HUMAN DEVELOPMENT"

kountryadd "Venezuela (Bolivarian Republic of)" to "Venezuela" add
kountryadd "Bolivia (Plurinational State of)" to "Bolivia" add
kountry country, from(other) stuck
rename _ISO3N_ geo
kountry geo, from(iso3n) to(iso2c)
rename _ISO2C_ cntry
drop geo 

// Prepare GII variable
rename C gii
label var gii "Gender Inequality Index"
replace gii = "" if gii == ".."
destring gii, replace

// Identify countries included in the ESS round 3
generate ess = (inlist(cntry, "AT", "BE", "BG", "CY", "DK", "EE", "FI", "FR") ///
              | inlist(cntry, "DE", "HU", "IE", "NL", "NO", "PL", "PT", "RU") ///
              | inlist(cntry, "SK", "SI", "ES", "SE", "CH", "UA", "GB"))

// Sort countries by GII
egen order_ = rank(gii), unique

// Plot
twoway (bar gii order_, horizontal) ///
       (bar gii order_ if ess, horizontal fcolor(gs1)) ///
      , ysize(8) legend(order(1 "All countries" 2 "Countries in ESS round 3") ring(0)) ///
        xscale(alt) ytitle("") ylabel(none) xlabel(0 (.1) .8, grid) ///
        note(" " "{it:Source:} Human Development Report 2015, Table 5.", span)