Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Looping graphs and changing graphs name


From   Evelyne Fournier <efournier@chu-besancon.fr>
To   <statalist@hsphsun2.harvard.edu>
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<efournier@chu-besancon.fr>  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
    vwiggins@stata.com

*
*   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 : efournier@chu-besancon.fr
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:efournier@chu-besancon.fr
tel;quoted-printable;work:18314 (depuis l'int=C3=A9rieur) ou 03 81 21 83 14
version:2.1
end:vcard



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index