********************************************************************************
************************************
cd "F:\Intergenerational_Health_12_9_2021\Replication_EHB_12_20_2021\progs\Figures"
clear all
set more on 
set matsize 11000
#delimit ;
graph set window fontface Century;
use .\..\..\data\output\natality_1969_2004_clean_collapsed_merged_cohort_var_def , clear ;
keep if ymcaid==1966;
gen age_exp=ymcaid-birth_cohort;
replace age_exp=0 if age_exp<0;
gen b=45-age_exp;
egen t0=min(birth_cohort);
egen t3=max(birth_cohort);
gen t1=1948;
gen t2=1966;
gen U=45*_n/_N;
*tab U;
replace U=0 if U<0;
replace U=45 if U>45;
gen xl=18;
gen c=0;
gen B = age_exp + b ;
gen C = age_exp + b + c ;
gen date=birth_cohort;
gen Y1=-1*U+1966.5;
gen Y2=-1*U+1965.5;
replace Y1=. if U>30;
replace Y2=. if U>30;


twoway (rarea t1 t2 U,   color(blue%60) ) || 
(rarea Y1 Y2 U,   color("48 6 127") fintensity(90)) || 
 (bar age_exp date,horizontal color(khaki%2) lwidth(vvthin) lcolor("178 62 120")) || 
(rbar age_exp B date,horizontal color(eltgreen%3) lwidth(vvthin) lcolor("178 62 120")) || 
(pcarrowi 1950 16 1952 18, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1948 18 1950 20, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1946 20 1948 22, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1951 15 1949 13, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1949 17 1947 15, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1947 19 1945 17, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||

(pcarrowi 1936 40 1938 40, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1948.8 40 1946 40, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1948.2 40 1953 40, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1965.8 40 1962 40, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1976 40 1974 40, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1966.1 40 1968 40, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1975 18 1975 11, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(pcarrowi 1975 0 1975 6, lcolor(black) mcolor(black) lwidth(thin) mlwidth(thin) ) ||
(scatteri 1951 21 "Post-Medicaid Ages", msymbol(i) mlabpos(0) legend(off) mlabangle(-40) mlabcolor("0 0 0") mlabsize(2.5)) ||
(scatteri 1946 14 "Pre-Medicaid Ages", msymbol(i) mlabpos(0) legend(off) mlabangle(-40) mlabcolor("0 0 0") mlabsize(2.5))
,
xline(18, lcolor(red) lwidth(thick)) 
yline(1966, lcolor(red) lwidth(thick)) 
yline(1948, lcolor(red) lwidth(thick))
text( 1942 40 "Unexposed", orient(vertical) size(2.5))
text( 1971 40 "Fully" "Exposed", orient(vertical) size(2.5))
text( 1957.5 40 "Partially" "Exposed", orient(vertical) size(2.5))
text( 1974 8.4 "Eligible" "Ages",  size(2.5))
ytitle("Birth Cohort",size(vsmall))
xtitle("Age",size(vsmall))
xscale(range(0 45))
xlabel(0(3)45 , labsize(tiny) grid  )
yscale(range(1936 1976))
ylabel(1936(1)1976 , labsize(tiny) angle(0) grid  )
legend(off)
;

	graph save .\..\..\figs\figure_3.gph , replace ;
	graph export .\..\..\figs\figure_3.emf , replace ;
	

       
