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

st: RE: about graphics


From   "Nick Cox" <[email protected]>
To   <[email protected]>
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 
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/



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