On Apr 26, 2013, at 2:30 PM, richgold@ix.netcom.com wrote:
> I am producing a set of line graphs (e.g., via -twoway line o time, by(id)-) and I want to add the value of a fourth variable as a "note" (or other form of text) to each of the graphs; is this possible? if yes, how?
There are probably better ways to do this, but one approach would be
tempvar obs
gen `obs' = _n
qui levelsof id, loc(ids)
foreach id of loc ids {
qui sum `obs' if id==`id'
line o time if id==`id', t1title(`id') note(`"`=note[`r(min)']'"') ///
name(p`id', replace)
loc plots "`plots' p`id'"
}
gr combine `plots', ycommon xcommon note("Graphs by id")
As you can see, this assumes that the var id is numeric and that the value of note (i.e., your 4th variable) is constant within unique values of id. Note that the graph this generates will not look *exactly* like that you get with the -by()- option, but you can make it so with a few additional graph options if you'd like.
-- Phil
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/