Jun 6, 2014

Random graphs (25): Line plot


use country refyear coeff age wstator hwactual exist2j hwactua2 if refyear == 2011 using eulfs.dta, clear

// Handle missing values:
replace hwactual = 0 if age < 15
replace hwactual = 0 if inlist(wstator, 3, 4, 5)
replace hwactua2 = 0 if inlist(exist2j, 1, .)
replace hwactua2 = 0 if age < 15

// Sum up working hours from first and second job
gen hours = hwactual + hwactua2

// Drop unnecessary variables
drop refyear wstator exist2j

// Collapse to calculate means
collapse (mean) hours [pweight = coeff], by(country age)

// Label variables
label define age2 02  "0{c 150}4"  07  "5{c 150}9" ///
                 12 "10{c 150}14" 17 "15{c 150}19" ///
                 22 "20{c 150}24" 27 "25{c 150}29" ///
                 32 "30{c 150}34" 37 "35{c 150}39" ///
     42 "40{c 150}44" 47 "45{c 150}49" ///
                 52 "50{c 150}54" 57 "55{c 150}59" ///
     62 "60{c 150}64" 67 "65{c 150}69" ///
                 72 "70{c 150}74" 77 "75{c 150}79" ///
                 82 "80{c 150}84" 87 "85{c 150}89" ///
                 92 "90{c 150}94" 97 "95+", modify
label value age age2
label define country  1 "AT"  2 "BE"  3 "BG"  4 "CH"  5 "CY" ///
                      6 "CZ"  7 "DE"  8 "DK"  9 "EE" 10 "ES" ///                    
                     11 "FI" 12 "FR" 13 "GR" 14 "HU" 15 "IE" ///
                     16 "IS" 17 "IT" 18 "LT" 19 "LU" 20 "LV" ///
                     21 "MT" 22 "NL" 23 "NO" 24 "PL" 25 "PT" ///
                     26 "RO" 27 "SE" 28 "SI" 29 "SK" 30 "UK" ///
                 , modify
label value country country

// Plot

twoway (line hours age if country == 30) ///
       (line hours age if country ==  7) ///
       (line hours age if country == 22) ///
       (line hours age if country == 10) ///
      , caption("{it:Source:} EU Labor Force Survey 2011, own calculations", span) ///
        ytitle("Hours worked per week per capita") xtitle("Age group") ///
        xlabel( 2 (5) 97, val ang(45)) ylabel(0 (5) 30) ///
        legend(label(1 "United Kingdom") ///
               label(2 "Germany") ///
               label(3 "The Netherlands") ///
               label(4 "Spain") ring(0) pos(1))