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]
Re: st: Looping graphs and changing graphs name
From
Evelyne Fournier <[email protected]>
To
<[email protected]>
Subject
Re: st: Looping graphs and changing graphs name
Date
Tue, 4 Dec 2012 09:44:33 +0100
Thank you very much Vince, it works like a charm. That's exactly what I
wanted to do.
Best,
Evelyne
Le 04/12/2012 03:31, Vince Wiggins, StataCorp a écrit :
Evelyne Fournier<[email protected]> is having a problem naming
graphs in a loop. Here is an excerpt of Evelyne's data,
loc clage incid morta
Système Nerveux 50-54 23.96 5.99
Système Nerveux 55-59 30.11 10.03
Système Nerveux 60-64 58.73 22.58
And, here is a simplification of the code,
levelsof loc
foreach lev in `r(levels)' {
preserve
keep if loc=="`lev'"
twoway line incid clage, name("`lev'", replace)
restore
}
To which, Stata replies,
Système Nerveux : .twowaygraph_g.new (line incid clage, sort) (line
morta clage, sort), title("Système Nerveux Central"): class type not
found
r(4018);
This is an unfortunate and unhelpful error message that we will improve
in a future update.
The source of the problem, however, is the contents of Evelyne's loc
variable. That variable includes spaces and extended ASCII characters,
neither of which are allowed in Stata names. See [U] 11.3 Naming
conventions.
One possible solution is to simply number the graphs with a leading
stub. For example,
local i 0
levelsof loc
foreach lev in `r(levels)' {
preserve
keep if loc=="`lev'"
twoway line incid clage, name(stub`++i', replace)
restore
}
-- Vince
[email protected]
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/
--
Evelyne Fournier
Epidémiologiste
Registre des Tumeurs du Doubs et du Territoire de Belfort
CHU Besancon Saint Jacques
25030 Besançon Cedex
Tel : 03 81 21 83 14
mail : [email protected]
site registre : http://www.chu-besancon.fr/registretumeursdoubs/
begin:vcard
fn:Evelyne Fournier
n:Fournier;Evelyne
org:CHU Besancon;Registre des tumeurs du Doubs
adr:;;2 Place Saint Jacques;Besancon;;25000;France
email;internet:[email protected]
tel;quoted-printable;work:18314 (depuis l'int=C3=A9rieur) ou 03 81 21 83 14
version:2.1
end:vcard