I am looping over a varlist to draw histograms. To each graph, I want to add an -xline- for the low and high extreme values (which I determine separately for each variable). I was wondering if there is a way to efficiently code this in a parallel loop? I have been playing around with the following code where I have defined three locals: the first is the var, which lists two variables that are to be looped over, the second and third macros are called high and low: these list the high and low extreme values of each variable in var (in the order that the variables are listed in var).
I am able to loop over var-- but how do I also loop over high and low sequentially?So that when the histogram command is graphing variable x, it takes the first element of high and low to make xlines etc.
Many thanks!
I am able to loop over var-- but how do I also loop over high and low sequentially?So that when the histogram command is graphing variable x, it takes the first element of high and low to make xlines etc.
Many thanks!
Code:
local var x y local high 100000 200000 local low 10 20 foreach v of var `var14' { #d ; histogram `v', frequency bin(50) color(red%30) ti("`v'", size(medsmall)) plotr(m(zero)) xlabel(#15, angle(90) nogrid labsize(vsmall)) xtitle("") xmtick(#15, grid tstyle(none)) xscale(noline) ylabel(#10, labsize(vsmall) nogrid angle(0)) ytitle("") ymtick(#10, grid tstyle(none)) yscale(noline) xline(`high', lpattern(dash) lcolor(blue%40)) xline(`low', lpattern(dash) lcolor(blue%40)) scheme(s2mono) plotregion(color(gray%30)) graphregion(color(white)) aspectratio(1) ; #d cr graph export "`v'_test.png", replace }
Comment