Jul 10, 2017

Using -sdmxuse- to download Eurostat data


// 1) Download data:
sdmxuse data ESTAT, dataset(ilc_di12) clear attributes
destring time, gen(year)

// Generate country name variable
replace geo = "GR" if geo == "EL"
kountry geo, from(iso2c) marker
rename NAMES_STD country
replace country = "Croatia" if country == "Yugoslavia"
drop if MARKER == 0 // Drop EU-28 etc. entries
drop if country == "European Union"
drop MARKER

// Identify EU-15
generate eu15 = (inlist(geo, "AT", "BE", "DK", "FI", "FR", "DE", "GR", "IE") ///
               | inlist(geo, "IT", "LU", "NL", "PT", "ES", "SE", "UK")) 

sparkline value year if eu15, over(country) ysize(10) ///
          note(" " "{it: Source:} Eurostat, ilc_di12, date of extraction: 2017-07-10", span) ///
          xlabel(1995 (10) 2015) xmtick(1995 (5) 2015) ///
          xtick(1995 (1) 2016) ///
          ytitle(" ") xtitle("") ///
          title("Income inequality") ///
          subtitle("(Gini of equivalised disposable income)") ///
          name(regular, replace)
// 2) Download data as time series: sdmxuse data ESTAT, dataset(ilc_di12) clear timeseries destring time, gen(year) twoway (scatter gini_hnd_uk_a year, connect(L)) /// (scatter gini_hnd_de_a year, connect(L)) /// , xtitle("") /// ytitle("Income inequality" /// "(Gini of equivalised disposable income)") /// xlabel(1995 (5) 2015) xtick(1995 (1) 2015) /// ylabel(25 (5) 35) ytick(25 (1) 35) /// note(" " "{it: Source:} Eurostat, ilc_di12, date of extraction: 2017-07-10", span) /// legend(order(1 "United Kingdom" 2 "Germany") pos(5) ring(0)) /// name(timeseries, replace)