Dear Stata-users,

As I was working on my thesis, I was wondering about the following. I have made two figures with confidence intervals for a variable on expected retirement age (called 'rretage') per gender (called 'ragender') and grouped by current age of respondents (called 'ragey_e'). I have included the code below:

preserve
collapse (mean) mrretage = rretage (sd) sdrretage = rretage (count) nrretage = rretage if ragender ==1 , by(ragey_e)
generate rretageucl = mrretage + 1.96*sdrretage/sqrt(nrretage)
generate rretagelcl = mrretage - 1.96*sdrretage/sqrt(nrretage)


twoway rcap rretagelcl rretageucl ragey_e, xtitle(Current age) ytitle(Expected retirement age) subtitle(By current age) saving(confidenceintmales.gph)


restore

preserve
collapse (mean) mrretage = rretage (sd) sdrretage = rretage (count) nrretage = rretage if ragender ==2 , by(ragey_e)
generate rretageucl = mrretage + 1.96*sdrretage/sqrt(nrretage)
generate rretagelcl = mrretage - 1.96*sdrretage/sqrt(nrretage)


twoway rcap rretagelcl rretageucl ragey_e, xtitle(Current age) ytitle(Expected retirement age) subtitle(By current age) saving(confidenceintfemales.gph)

restore

They look like the picture I added (after combining the figures).

My question is: Is there a way to combine the confidence intervals into one figure, i.e. place them 'over' each other with different colors?

Hope someone can help and please let me know if my question is not clear.

Best,

Floor