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

st: Re: graph title q


From   Christopher Baum <[email protected]>
To   [email protected]
Subject   st: Re: graph title q
Date   Sat, 17 May 2003 08:50:13 -0400


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)]
g
raph bar total male female if country=="`c'", title("`c' `y'")
}


Kit




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