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: Looping through graphs w/ foreach?


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Looping through graphs w/ foreach?
Date   Thu, 18 Aug 2011 16:33:23 +0100

For a slideshow, put -more- as the last line within the loop.

local empcategories "EMPJ EMPK EMPL EMPM EMPNEMPO EMPP EMPQ EMPR"
foreach var of local empcategories {
local graphtitle : variable label `var'
twoway line `var' `var'_neg Year if Mnemonic==trim("AMSTER")
more
}

In addition, note that your local -graphtitle- does nothing useful
unless you put the text somewhere on the graph.

Nick

On Thu, Aug 18, 2011 at 4:28 PM, Suran, Luciana @ CBRE EA
<[email protected]> wrote:

> I am relearning Stata after a few years away using other statistical
> software so apologies for the introductory nature of this question.
>
> I have a time series dataset for ~ 20 cities - showing employment levels
> a number of different sectors (EMPJ, EMPK, EMPL, etc.), with each
> employment sector having a "base" (e.g. EMPJ) and "negative" (e.g.
> EMPJ_neg) forecast scenario.
>
> How can I loop through graphs showing the scenarios for each of the
> (many) employment categories? I can't use "graph combine" as too may
> graphs are displayed and I can't closely examine them. Is there a way I
> could hit the spacebar or Enter key to move to the next graph? And can
> all the grpahs be saved at once in one file?
>
> I tried the following code, but only the final variable, EMPR, is
> displayed:
>
> local empcategories "EMPJ EMPK EMPL EMPM EMPNEMPO EMPP EMPQ EMPR"
> foreach var of local empcategories {
> local graphtitle : variable label `var'
> twoway line `var' `var'_neg Year if Mnemonic==trim("AMSTER")
> }
>
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index