Hey Everyone,

I am trying to plot multiple graphs using a for loop. At the time, I am trying to make the code change the title for each graph.

I have data from 60 cities and 21 industries. The code I'm using is not generating the correct title.

Code:
egen city_group = group(msa)
egen industry_group = group(industry_code)

gen long obs = _n
foreach i of num 1/60{
foreach j of num 1/21{
su obs if name_city == "`i'", meanonly
local t = name_city[r(min)]
su obs if industry_title == "`j'", meanonly
local s = industry_title[r(min)]
twoway line export year if city_group == `i' & industry_group == `j', xtitle("Year") ytitle("coeficient export") title("`t' `s'")
graph save graph_`i'_`j', replace
}
}
Thanks,
Hussain