Sep 7, 2017

Random graphs (111): Line plot

clear
import excel ccf.xlsx, sheet("Completed cohort fertility") cellrange(A2:AH39) firstrow

xpose, clear varname

local y = 1935
foreach x of numlist 1/37 {
  rename v`x' ccf`y'
  local y = `y' + 1
}

drop in 1

reshape long ccf, i(_varname) j(cohort)
replace ccf = . if ccf == 0
rename _varname country

twoway (line ccf cohort if country == "USA") ///
       (line ccf cohort if country == "Italy") ///
       (line ccf cohort if country == "GermanyWest") ///
       (line ccf cohort if country == "GermanyEast") ///
      , xtitle(Birth cohort) ytitle("Completed cohort fertility") ///
        ylabel(, format(%6.1f)) ///
        legend(order(1 "USA" 2 "Italy" 3 "Germany (West)" 4 "Germany (East)"))