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

st: Re: autogeneration of graphs


From   Christopher F Baum <[email protected]>
To   [email protected], [email protected]
Subject   st: Re: autogeneration of graphs
Date   Sat, 27 Jul 2002 08:19:29 -0500

--On Saturday, July 27, 2002 2:33 -0400 Scott wrote:

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)
This will certainly work, but will cause a number of graphs to just display on the screen. Perhaps adding saving( ) would be useful. However that brings up a limitation of by (which is a wonderful feature, but sometimes does not do all that one needs...) It also does not allow labelling of the graphs. A modified
approach using Nick Cox' 'levels' (ssc desc levels):

use auto
g str1 mm = substr(make,1,1) * equiv of census tract
levels mm,macname(cars)
foreach c of local cars {
graph price mpg if mm=="`c'", saving(cars_`c',replace) ti("Cars of make `c'")
}

This will create files cars_A.gph, cars_B.gph, etc., with the graph titles containing information on the category being graphed.

In fact one can then do asomething like

graph using cars_A cars_B cars_C cars_D


Or use 'translate' to change all of the graphs into some other format (such as eps), etc.

Kit
*
* 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