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

Re: st: Graph title question


From   Ulrich Kohler <[email protected]>
To   [email protected]
Subject   Re: st: Graph title question
Date   Mon, 19 May 2003 13:03:39 +0200

Friedrich Huebler wrote:
> How can I add the contents of a variable to a graph title? I work
> with data like this:
>
> country  year  total  male  female
> Albania  1999     20    15      25
> Algeria  2000     10    15       5
> Angola   2000     30    35      25
>
> 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.


If the data has is one line per country  the following might  be an option 
(not tested):

local i 1
levels country, local(countries)
	 foreach c of local countries {
		local year = year[`i']
	         graph bar total male female if country=="`c'", title("`c' `year'")
		local i = i+1
 }


regards
uli

-- 
[email protected]


*
*   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