Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Re: automatic line graph generation from tabsum function


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Re: automatic line graph generation from tabsum function
Date   Sat, 27 Jul 2002 12:49:22 +0100

Gretchen Caspary
 
> > Graphics question.
> >
> > I want to be able to automatically produce a series of 
> simple line graphs.
> >
> > I am doing a tabsum with "census tract" and "month" on 
> the x and y axis,
> > respectively, and showing mean "number of claims" in the 
> body of the
> table:
> >
> > tab census month, sum(num_claims)
> >
> > which will produce a big table.  I want to be able to 
> *automatically*
> > generate a line graph for every "census tract" row.

Scott Merryman
 
> If I understand this, you want to graph the mean number of 
> claims by month
> for each census tract.
> 
> First generate the mean number of claims:
> egen average_claim = mean(num_claims) by(census)
> 
> Sort variables so they are in the correct census and month order:
> sort census month
> 
> graph:
> by census: graph average_claim year, c(l)

Cleaning up a few typos here

egen average_claim = mean(num_claims), by(census month) 
sort census month 
by census: graph average_claim month, c(l) 

In fact, I think the following should work 

bysort census month: egen average_claim = mean(num_claims) 
by census : graph average_claim month 

Nick 
n.j.cox@durham.ac.uk 
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index