Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: xtline with labels


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: xtline with labels
Date   Wed, 6 Sep 2006 18:34:46 +0100

If your data include only 10 states, then it's
more like 

decode id, gen(ID) 

forval i = 1/10 { 
	local label = ID[`i'] 
	xtline ... if id == `i', subtitle("`label'") 
}

or 

forval i = 1/10 { 
	xtline ... if id == `i', subtitle("`= ID[`i']'") 
}

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Scott
> Cunningham
> Sent: 06 September 2006 18:23
> To: [email protected]
> Subject: Re: st: RE: xtline with labels
> 
> 
> Thanks Nick.  -ecode- and -decode- are new to me.  I'm looking it up  
> now.
> 
> 10 states - I'm only looking at 10 states right now.
> 
> scott
> 
> On Sep 6, 2006, at 1:18 PM, Nick Cox wrote:
> 
> > First off, you need to read up some basics on -encode-
> > and -decode-.
> >
> > I know of 50 U.S. states, so I am not clear how you get
> > 10 different graphs with 10 different states on each.
> > I guess 10 different graphs with 5 states on each.
> >
> > First, you have to set up your grouping in advance.
> >
> > Let a variable -group- indicate each subset of states.
> > Set it up so that the values run from 1 to 10.
> >
> > A minimal recipe which you will want to complicate is
> >
> > decode id, generate(ID)
> >
> > forval i = 1/10 {
> > 	levelsof ID, local(IDS) clean
> > 	xtline sexratio if group == `i', subtitle("`IDS'")
> > }
> >
> > Nick
> > [email protected]
> >
> > Scott Cunningham
> >
> >> I have a small dataset containing the ratios of men to women for
> >> blacks and whites at the United States level that varies by age.  I
> >> want to use -xtline- to create 10 different graphs, with 
> the name of
> >> 10 different U.S. states above each graph.  The data is tsset as:
> >>
> >> . tsset id age
> >>
> >> where "id" is a numerical identifier of a United States state
> >> and age
> >> is the sex ratio for that state at different ages.  I've 
> labeled the
> >> values of "id" using "label define idlbl # [name]" so that
> >> each value
> >> has its accompany US State.  Is there a way to cause xtline
> >> to report
> >> the names of each state used to create each independent sex ratio?
> >> Because, when I do this:
> >>
> >> . xtline sexratio
> >>
> >> it reports a number above each graph.

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index