Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Re: graph title q


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: Re: graph title q
Date   Sat, 17 May 2003 10:10:48 -0400

Even less work is:

gen countryyear=country+" "+string(year)
levels countryyear, local(countries)
foreach c of local countries {
   graph bar total male female if countryyear=="`c'", title("`c'")
 }

Michael Blasnik
[email protected]


----- Original Message ----- 
From: "Christopher Baum" <[email protected]>
To: <[email protected]>
Sent: Saturday, May 17, 2003 8:50 AM
Subject: st: Re: graph title q


> 
> On Saturday, May 17, 2003, at 02:33 AM, Frederick wrote:
> 
> > The following commands produce bar graphs for individual countries.
> >
> > levels country, local(countries)
> > foreach c of local countries {
> >   graph bar total male female if country=="`c'", title("`c'")
> > }
> >
> > The title contains the country name and I would like to add the year,
> > as in "Albania 1999." This looks like a trivial problem but I cannot
> > find a solution.
> 
> Assuming you only have one year per country, this is a bit less work 
> than checking every possible year/country combination:
> 
> levels country, local(countries)
> g n = _n
> foreach c of local countries {
> summ n if country=="`c'",meanonly
> local y = year[r(min)]
> graph bar total male female if country=="`c'", title("`c'  `y'")
> }
> 
> Kit
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index