Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: st: loop for graphs


From   Christopher Baum <kit.baum@bc.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   re: st: loop for graphs
Date   Fri, 8 Jul 2011 00:25:10 -0400

<>
I have 3 dependent variables (a1,b1,c1) that i want plot
against 1 var (x). i will be using scatter plot and  hope to use these
commands

foreach var of varlist a1-c1 {
graph twoway (scatter `var' x ) (lfit `var' x), saving(gr.gph)
}

with those line, i will only get the last graph but no the other 2
graphs.


Try

foreach var of varlist a1-c1 {
	graph twoway (scatter `var' x ) (lfit `var' x), saving(`var'.gph, replace)
}

Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
                              An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
   An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html




*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index