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 Bornschein <[email protected]>
To
[email protected]
Subject
Re: st: Loop: matching variables (in order)
Date
Wed, 20 Nov 2013 16:31:16 +0100
Well, no.
Ich want to produce one graph with 2 lines: tsline `x' || tsline `y'
(syntax simplified) where x is for example apple and y is apple_m30. So
have the variables (these and more thats why I need a loop)
x: apple nokia biorad
y: apple_m30 nokia_m30 biorad_m30
And the graph needs to be (simplified): tsline apple || tsline apple_m30
then: tsline nokia || tsline nokia_m30
and so on.
And sorry for the double post, got an error message when I wrote first.
-Nick
Am 20.11.13 16:18, schrieb Nick Cox:
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/
*
* 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/