Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: How Can I Add Different Titles to Multiples Graphs Created in a Loop
From
"Martin Weiss" <[email protected]>
To
<[email protected]>
Subject
st: RE: How Can I Add Different Titles to Multiples Graphs Created in a Loop
Date
Wed, 7 Apr 2010 20:44:32 +0200
<>
You can employ the -var label-s to create a mapping from the variable names
to the content, though. During the creation of the graphs, you extract the
labels as in -help extended_fcn-:
*******
clear*
set obs 10000
gen byte A=runiform()<.3
la var A "bronchitis"
gen byte B=runiform()<.45
la var B "cholera"
gen byte C=runiform()<.7
la var C "common cold"
gen byte var= /*
*/ irecode(runiform(),0,.2,.5,1)
loc sick "A B C"
foreach z of local sick{
graph pie var, over (`z') /*
*/ name(`z', replace) /*
*/ title(`:var label `z'') /*
*/ nodraw
}
graph combine A B C, rows(1)
*******
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nicolás Rojas
Sent: Mittwoch, 7. April 2010 20:30
To: [email protected]
Subject: st: How Can I Add Different Titles to Multiples Graphs Created in a
Loop
Hello everyone,
*I am making descriptive statistics from a
data base about people who get sick and have to decide whether they go
to an hospital or not within the last twelve months. Therefore, people
can get sick of more than one sickness.
* My problem is how to make pie graphs with a
loop and put titles to every graph in the loop.
*Thus, imagine I have 15 dummy variables
indicating whether people go to a hospital for 15 different kind of
sickness (say A, B, C D .. O ) . If they didn't get sick the variable
has a missing value.
then I could use the following:
local sickness "A B C D ... O"
foreach z of local sickness {
graph pie, over (`z') saving(`z')
}
However, what I want to do is to put titles with the real name of the
sickness while running the loop. That is, I want to put titles like
Bronchitis for variable A Sinusitis for variable B etc.
Obviusly it would be easy to write:
local sickness "A B C D ... O"
foreach z of local sickness {
graph pie, over (`z') saving(`z') title(`z')
}
But the problem is that woud put titles that are not the real name of
the variable (A B C instead of bronchitis sinusitis). I could rename
the variables so thar instead of A B C they are named bronchitis
sinusitis etc. The problem with that is that there are sickness that
have compund names so the would be named, for example, common_cold .
I don't want to have graphs with titles that have an underscore. Also,
as people can get more than one sickness by() and labels would not
help either.
Does anybody know what to do??
Thanks,
Nicolas Rojas
Pontifical Catholic University of Chile
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/