ann e fitzmaurice
>
> I want to find a way of displaying categorical information
> as a line graph.
> Although this is not usually the best way to go about things, it is
> expedient in a situation I have in mind.
>
> I have the raw data and want to work with the data file.
>
> So, one variable (say, region) divided into x categories. I
> want to show
> the percentage of other variables (say, urban population
> and literacy) in
> each of the regions - with regions along the X axis and the
> different
> percentages of urban population/literacy (2 separate lines one for
> urban population and one for lieracy) indicated by points within
> the graph. I also want to connect all the different regional
> percentages of urban population by a line (and do the same for
> literacy).
>
This is just a standard line graph, as you say.
The only work, I think, is calculating the
percents directly.
I'll assume you are using Stata < 8. An analogue
of your problem uses the census.dta distributed with
Stata, with states aggregated into regions:
. u census
We'll add population for all the states
in each region:
. egen pcpop = sum(pop), by(region)
To get the national population we
. su pop
and then we get the percents in each
region using the r(sum) that leaves behind
. replace pcpop = 100 * pcpop / r(sum)
In this case, region is a categorical
variable represented by integers with
labels:
. gra pcpop region , xla(1 2 3 4) yla c(l) sort
The other percent calculation is naturally
of the same form.
Nick
[email protected]
*
* 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/