I am using Stata 13 and panel data over four years in long format. I would like to plot employment rates for 25 countries, each with its own line and in one graph, on a common x and y axis and would like to do this in a loop to save space. My x axis should be the year and y axis the employment rate.My code, however, generates 25 different mini-graphs within one graph box, each however on its own x and y axis. I have done some searching but cannot seem to combine these 25 graphs into one.
My code is below, where c refers to country (string), ER_w is the employment rate variable and y is the year. I have excluded labels and scales here for simplicity.
Any advice is much appreciated!
Cortnie Shupe
PhD Candidate
set graphics off
qui levelsof c, loc(levels)
foreach lev of loc levels {
preserve
keep if c=="`lev'"
tw (line ER_w y, sort), name(gr`lev', replace)
loc grnames "`grnames' gr`lev'"
restore
}
set graphics on
gr combine `grnames', altshrink nocopies xcommon
My code is below, where c refers to country (string), ER_w is the employment rate variable and y is the year. I have excluded labels and scales here for simplicity.
Any advice is much appreciated!
Cortnie Shupe
PhD Candidate
set graphics off
qui levelsof c, loc(levels)
foreach lev of loc levels {
preserve
keep if c=="`lev'"
tw (line ER_w y, sort), name(gr`lev', replace)
loc grnames "`grnames' gr`lev'"
restore
}
set graphics on
gr combine `grnames', altshrink nocopies xcommon
Comment