Using the codes below, I could nicely plot my data and retain my plots of interest using gr combine. However, the profile variable has several levels which make the coding so hectic. Is there any way to wrap up the codes below?
Thanks for the help.
NM
twoway (line Obs_q1 _margin age if profile=="00" & gender==0 , sort ), title("00") legend(label(1 "Observed") label(2 "modeled") ) saving(00, replace)
twoway (line Obs_q1 _margin age if profile=="01" & gender==0 , sort ), title("00") legend(label(1 "Observed") label(2 "modeled") ) saving(01, replace)
twoway (line Obs_q1 _margin age if profile=="02" & gender==0 , sort ), title("00") legend(label(1 "Observed") label(2 "modeled") ) saving(02, replace)
twoway (line Obs_q1 _margin age if profile=="03" & gender==0 , sort ), title("00") legend(label(1 "Observed") label(2 "modeled") ) saving(03, replace)
twoway (line Obs_q1 _margin age if profile=="04" & gender==0 , sort ), title("00") legend(label(1 "Observed") label(2 "modeled") ) saving(04, replace)
gr combine 00.gph 01.gph , title("Modeled and Observed")
twoway (line Obs_q1 _margin age if profile=="01" & gender==0 , sort ), title("00") legend(label(1 "Observed") label(2 "modeled") ) saving(01, replace)
twoway (line Obs_q1 _margin age if profile=="02" & gender==0 , sort ), title("00") legend(label(1 "Observed") label(2 "modeled") ) saving(02, replace)
twoway (line Obs_q1 _margin age if profile=="03" & gender==0 , sort ), title("00") legend(label(1 "Observed") label(2 "modeled") ) saving(03, replace)
twoway (line Obs_q1 _margin age if profile=="04" & gender==0 , sort ), title("00") legend(label(1 "Observed") label(2 "modeled") ) saving(04, replace)
gr combine 00.gph 01.gph , title("Modeled and Observed")
0 Response to Wrapping up twoway plots using loop
Post a Comment