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

st: RE: about graphics

From   "Nick Cox" <>
To   <>
Subject   st: RE: about graphics
Date   Wed, 20 Nov 2002 09:26:00 -0000

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

In addition, some of the technique at
may be useful background. 

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index