I have been struggling with the
Code:
foreach
Code:
local Obv profit hkgovsme_result marketing sale_no moti_self
local Sbv sex fail hkgovsme_app intelp esale fund_no esale_eu esale_none sale_no sorted_nation
local Ocv num_busp ft pt gba_ft ebus_12m
local Scv yr_bus pt num_busp buscha_uncertain hkgovsme gba_busyr
foreach T of newlist Sb Sc{
foreach n of local `T'v{
local label: variable label `n'
graph hbar, ///
over(`n') over(tech) ///
stack percent ///
asyvars ///
blabel(bar, position(center) format(%9.0f) color(white) size(2.5)) ///
legend(r(1) size(2)) ///
yline(50) ///
ytitle("%") ///
b1title("`label'") ///
note("Conditional observation: Startups")
graph export `add'\`T'v_`n'.png, replace
}
}
foreach T of newlist Ob Oc{
foreach n of local `T'v{
local label: variable label `n'
graph hbar, ///
over(`n') over(startup) ///
stack percent ///
asyvars ///
blabel(bar, position(center) format(%9.0f) color(white) size(2.5)) ///
legend(r(1) size(2)) ///
yline(50) ///
ytitle("%") ///
b1title("`label'") ///
note("Conditional observation: ALL")
graph export `add'\`T'v_`n'.png, replace
}
}
- objects in -newlist(.)-: Sb, Sc and Ob, Oc
- the variables in the - over(.)-: tech, startup
Thank you
0 Response to Nested foreach
Post a Comment