Code:
decode Stage, gen(Stage_str)
local stages 0 1 2 3 4
#delimit ;
local diseases_needed
    Asthma
    "Pain, nociceptive, general"
    "HIV"
    "Cancer"
    
;
#delimit cr
foreach disease of local diseases_needed {
    foreach stage of local stages {
        
        local graph_title = "Number of " + Stage_str + " Events over time (" + Disease + ")"
        histogram year if Disease=="`disease'" & Stage==`stage',  width(1) ///
            frequency color("${orange}") ylabel(#10, angle(0)) xtitle("Year") ///
            title("`graph_title'")
    graph export "${dodir}\graphs\`disease'_`stage'.pdf", as(pdf) replace
    }
    }
0 Response to Graphing in a nested loop
Post a Comment