Jan 5, 2016

Random graphs (55): Box plots

wbopendata, indicator(NY.GDP.PCAP.KD) clear

// Select countries
#delimit ;
keep if inlist(countrycode, "AUS", "AUT", "BEL", "CAN", "DNK") |
        inlist(countrycode, "FIN", "FRA", "DEU", "GRC", "ISL") |
        inlist(countrycode, "IRL", "ITA", "JPN", "NLD") |
        inlist(countrycode, "NZL", "NOR", "PRT", "ESP") |
        inlist(countrycode, "SWE", "CHE", "USA") ;
#delimit cr

// Get rid of unnecessary years
keep countryname countrycode iso2code region regioncode ///
     indicatorname indicatorcode ///
     yr1960 yr1970 yr1980 yr1990 yr2000 yr2010
  
// Reshape into long format
reshape long yr, i(countryname) j(year)

// Prepare outcome variable
rename yr gdppc
label var gdppc "GDP per capita (constant 2005 US$)"

// Plot
graph box gdppc, over(year)