I would like to draw a scatter plot for a variable list with yline () of Average of each variable. However, I wrote this loop but unfortunately, as I did it uses each of the average values of the other variables as well.
Average of variables av_rule_law av_gov_effec av_gov_exp_health_gdp av_infant_mortality : -0.6452087 -0.5824026 5.376345 66.99238
Please, help me to correct specify the mean of each variable as yline (value).
Thanks,
Best.
Average of variables av_rule_law av_gov_effec av_gov_exp_health_gdp av_infant_mortality : -0.6452087 -0.5824026 5.376345 66.99238
Code:
foreach var of varlist av_rule_law av_gov_effec av_gov_exp_health_gdp av_infant_mortality { foreach i in -0.6452087 -0.5824026 5.376345 66.99238 { twoway scatter `var' av_cgdp, mlabel(code) xline(0, lpattern(dash)) yline(`i', lpattern(dash)) lcolor(. green) mlabgap(5) scheme(vg_brite) mlabposition(12) mlabsize(small) mfcolor(blue) mlcolor(black) mlwidth(medthick) msize(small) /// note("Source: simulation", size(medsmall)) graph export "C:\Users\Perron\Downloads\Clairant\average_`var'_`i'.png", as(png) width(1200) replace } }
Thanks,
Best.
Comment