Hi statalist,

I would like to make a graph using lowess command by treatment group.
I have 10 treatment groups: treat1, treat2,....,treat10

I tried
code:

twoway (lowess occupplace coh if treat1==1 & age>=25 & age<80 & occupplace<50) (lowess occupplace coh if treat1==0& age>=25& age<80 & occupplace<50), ytitle("Life time work place") xtitle("Birth Cohort (age)") legend (on order(1 "treat" 2 "control"))
graph export graph1.png

twoway (lowess occupplace coh if treat2==1 & age>=25 & age<80 & occupplace<50) (lowess occupplace coh if treat1==0& age>=25& age<80 & occupplace<50), ytitle("Life time work place") xtitle("Birth Cohort (age)") legend (on order(1 "treat" 2 "control"))
graph export graph2.png

twoway (lowess occupplace coh if treat3==1 & age>=25 & age<80 & occupplace<50) (lowess occupplace coh if treat1==0& age>=25& age<80 & occupplace<50), ytitle("Life time work place") xtitle("Birth Cohort (age)") legend (on order(1 "treat" 2 "control"))
graph export graph3.png


.
.
.

It works, but it is too long and I think there should be more clever way to do that.

Thus, I tried this

code:

local continuous treat1-treat10
foreach i of local continous {
twoway (lowess occupplace coh if `i'==1& age>=25 & age<80 & occupplace<50) (lowess occupplace coh if `i'==0& age>=25 & age<80 & occupplace<50) ,ytitle("Life time work place") xtitle("Birth Cohort (age)") legend (on order(1 "treat" 2 "control"))
graph export graph`i'.png
}


However it does not work...
Could you help me out?
Thank you in advance.