Bookmark and Share

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: Loop: matching variables (in order)


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Loop: matching variables (in order)
Date   Wed, 20 Nov 2013 15:18:05 +0000

The key here, if I understand you correctly,  is that you need one
loop, not two.  You are halfway there with your graph names. Also,
-tsline- can take a varlist

foreach x of varlist apple-biorad {
      tsline `x' `x'_m30 if datum >= `=date("01jan2010", "DMY")'
      graph export Grafiken/`x'_m30.png, replace
}

Nick
[email protected]


On 20 November 2013 15:12, Nick Bornschein <[email protected]> wrote:

> I have written the following loop, but there is a mistake when
> creating the graphs I cannot solve.
> First of all, I have an ordered list of x variables and an ordered
> list of y variables. I want to create an graph (tsline) with 2 lines,
> where I want use the first variable of the x variables and the first
> variable of the y variables, then I want to create the next graph with
> 2 lines with the second variable of the x variables and the second
> variable of the y variables. How can I write that into the loop?
>
>
> foreach x of varlist apple-biorad {
>     foreach y of varlist apple_m30-biorad_m30 {
>       tsline `x' if datum >= `=date("01jan2010", "DMY")' || tsline `y'
> if datum >= `=date("01jan2010", "DMY")'
>       graph export Grafiken/`x'_m30.png, replace
>     }
> }
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index