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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: the use of loop function in Stata


From   "Dr. Till Ittermann" <Itterman@uni-greifswald.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: the use of loop function in Stata
Date   Tue, 13 Mar 2012 15:44:41 +0100

Hi,

I would loop over lname not var:

foreach lname in lnamelist {
histogram `lname',  by(AID4, col(1))
graph save histogram`lname'
}



m 13.03.2012 15:36, schrieb Rosie Chen:
Nick, thank you very much for the further advice, which makes the syntax more efficient. Given the loop syntax I have, how to save all the histogram graphs? If I use the code below, the error message says: "file histogram.gph already exists".


foreach var of varlist lp*{

     histogram `var',  by(AID4, col(1))

     graph save histogram
}


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


--
Till Ittermann, Dr. rer. med.
Institut for Community Medicine - SHIP-KEF
Walther-Rathenau-Str. 48
17487 Greifswald

Phone: ++49 3834 867552
  Fax: ++49 3834 866684

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