Jul 27, 2017

Random graphs (105): Scatterplot

// Open ISSP data
use C_ALPHAN SEX V51 WEIGHT using ZA4350_v2-0-0.dta, clear

// Fix country variable
replace C_ALPHAN = "BE" if C_ALPHAN == "BE-FLA"
replace C_ALPHAN = "DE" if C_ALPHAN == "DE-E"
replace C_ALPHAN = "DE" if C_ALPHAN == "DE-W"
replace C_ALPHAN = "UK" if C_ALPHAN == "GB-GBN"

// Recode job satisfaction
recode V51 (7 = 0 "Completely dissatisfied") ///
           (6 = 1 "Very dissatisfied") ///
           (5 = 2 "Fairly dissatisfied") ///
           (4 = 3 "Neither satisfied nor dissatisfied") ///
           (3 = 4 "Fairly satisfied") ///
           (2 = 5 "Very satisfied") ///
           (1 = 6 "Completely satisfied"), gen(jobsat)
label var jobsat "Job satisfaction"

// Recode sex
gen female = (SEX == 2) if !missing(SEX)
label define female 0 "Male" 1 "Female"
label val female female
label var female "Sex"
drop if missing(female)

// Get rid of old variables
drop SEX V51

// Collapse and reshape data
collapse jobsat [pw = WEIGHT], by(C_ALPHAN female)
reshape wide jobsat, i(C_ALPHAN) j(female)

label var jobsat0 "Job satisfaction: men"
label var jobsat1 "Job satisfaction: women"

// Plot
twoway (scatter jobsat0 jobsat1 if jobsat0 > jobsat1, mlabel(C_ALPHAN) mlabpos(9)) ///
       (scatter jobsat0 jobsat1 if jobsat0 < jobsat1, mlabel(C_ALPHAN) mlabpos(6)) ///
       (function y = x, range(3.5 5.1))  ///
     , xlabel(3.5 (.5) 5.0, format(%6.2f)) ///
       ylabel(3.5 (.5) 5.0, format(%6.2f)) ///
       ytitle("Job satisfaction: men") ///
       xtitle("Job satisfaction: women") ///
       title("Cross-national variation in the gender gap in job satisfaction", span) ///
       note(" " "{it:Source:} International Social Survey Program (ISSP) 2005, doi:10.4232/1.11648", span) ///
       legend(off) name(figure1, replace)