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.
Related Posts with loop for if for making graphs...
Adding mean and sd to estpost / esttabHello everyone I want to add two extra columns for mean and standard deviation to my correlation ma…
Having issues with GcrobustvarDear scholars, I am having some issues using Gcrobustvar estimator for causality. After loading the …
Xtabond2 for system GMM. Please help me for codingHello to everyone, I am searching in terms of the effect of the uncertainty on the saving and in one…
Converting results from percentage point to percentHello STATALISTERS, I am estimating the effects of a program using the fixed effects model in which …
Wage increase for quarterly data in GermanyHello everyone! I have a huge dataset with 270864 observations on gross hourly wage split into diffe…
Subscribe to:
Post Comments (Atom)
0 Response to loop for if for making graphs...
Post a Comment