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

st: RE: Graph title question


From   Lee Sieswerda <Lee.Sieswerda@tbdhu.com>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Graph title question
Date   Fri, 16 May 2003 17:22:21 -0400

Hello Friedrich,

I don't know if this is the most efficient way to accomplish your task, but
it works:

levels country, local(countries)
levels year, local(year)
foreach c of local countries {
	foreach y of local year {
		capture graph bar total male female if country=="`c'" &
year==`y', title("`c' `y'")
	}
}


You need the -capture- before -graph bar-, otherwise your do-file will end
as soon as the -foreach- loops generate a country/year combination that
doesn't exist.

Best,
Lee

Lee Sieswerda, Epidemiologist
Thunder Bay District Health Unit
999 Balmoral Street
Thunder Bay, Ontario
Canada  P7B 6E7
Tel: +1 (807) 625-5957
Fax: +1 (807) 623-2369
Lee.Sieswerda@tbdhu.com
www.tbdhu.com


> -----Original Message-----
> From:	Friedrich Huebler [SMTP:huebler@rocketmail.com]
> Sent:	Friday, May 16, 2003 4:55 PM
> To:	statalist@hsphsun2.harvard.edu
> Subject:	st: Graph title question
> 
> 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.
> 
> Thank you for your help.
> 
> Friedrich Huebler
> 
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com
> *
> *   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/
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index