clear *Create paths to folders global data "C:\Users\aapo.kivinen\Dropbox (Aalto)\PhD\teaching\Principles_of_Economic_Analysis\aapo\session one\data" global output "C:\Users\aapo.kivinen\Dropbox (Aalto)\PhD\teaching\Principles_of_Economic_Analysis\aapo\session one\output" *To make nicer graphs *ssc install grstyle (Run this if you have not downloaded it yet) set scheme s2color grstyle init grstyle set plain use "$data\cleaned_data.dta", replace *Calculate total egen total = rowtotal(population1524-population6574) tabstat total, by(main_activity) stats(mean max min) * Make numbers into millions: replace total = total / 1000000 *Lets do the plotting step by step: twoway connected total year if main_activity == "Employed" *Change x-axis: twoway connected total year if main_activity == "Employed", xlabel(1989(10)2019) *Add title for y-axis: twoway connected total year if main_activity == "Employed", xlabel(1989(10)2019) ytitle("# of people in millions") legend(order(1 "Employed" 2 "Labour force" 3 "Total")) * Add other lines and legend: twoway (connected total year if main_activity == "Employed") (connected total year if main_activity == "Labour force") (connected total year if main_activity == "Total"), xlabel(1989(10)2019) ytitle("# of people in millions") legend(order(1 "Employed" 2 "Labour force" 3 "Total")) * Save output as a pdf-file graph export "$output\development.pdf", replace * Add another y-axis: twoway (connected total year if main_activity == "Employed") (connected total year if main_activity == "Labour force", yaxis(2)), xlabel(1989(10)2019) ytitle("# of people in millions") legend(order(1 "Employed (left axis)" 2 "Labour force (right axis)")) ytitle("# of people in millions", axis(2)) graph export "$output\development2.pdf", replace *Calculate change in gdp and in employment gen change_in_gdp = ((gdp-gdp[_n-1])/gdp[_n-1])*100 if year!=1987 gen change_in_Employed = ((total-total[_n-1])/total[_n-1])*100 if main_activity == "Employed" & main_activity[_n-1] == "Employed" & year!=1987 sum change_in_Employed change_in_gdp *Plot results twoway (scatter change_in_gdp change_in_Employed, mlabel(year) mlabsize(vsmall)) (lfit change_in_gdp change_in_Employed) if year>1987, ylabel(-10(5)10) xlabel(-10(5)10) legend(off) ytitle(%-change in gdp) xtitle(%-change in Employment) graph export "$output\correlation.pdf", replace