Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: the use of loop function in Stata
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: the use of loop function in Stata
Date
Tue, 13 Mar 2012 18:08:15 +0000
Till: I don't see that there is a distinction here. In terms of Rosie's syntax
histogram `var', by(AID4, col(1))
graph save histogram`var'
should work fine.
Nick
On Tue, Mar 13, 2012 at 3:28 PM, Steve Nakoneshny <[email protected]> wrote:
> You will also need to add the -replace- option to the histogram command.
>
> On 2012-03-13, at 8:44 AM, Dr. Till Ittermann wrote:
>
>> 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/