Hailing Zang
>
> How to save graphs in a loop? For example, I have the
> code:
>
> by t: graph price quantity
>
> Then I will get each graph for each t, but how can I
> save the graphs in a loop?
Here is one way to do it.
Download -levels- from SSC.
If t is a numeric categorical variable,
. levels t, local(levels)
. foreach l of local levels {
. graph price quantity if t == `l', saving(g`l') t1(`l')
. more
.}
The -more- is optional.
If t is string, it is the same apart from
... if t == "`l'" ...
There are relevant examples in
Stata Journal 2(2), 202-222 (2002)
or at
http://www.stata.com/support/meeting/8uk/fortitude.pdf
In addition, some of the technique at
http://www.stata.com/support/faqs/data/for.html
may be useful background.
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/