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 on April 23, and its replacement, is already up and running.

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

st: dynamic graphs

From   Rodrigo Briceño <>
Subject   st: dynamic graphs
Date   Fri, 28 Sep 2012 12:19:20 -0600

Dear Stata List Experts. I wrote a code to be able to run a set of 11
graphs (liq_an on the Y axis, SFID on the second Y axis, weeks on the
X axis). The code works perfectly, however there is one small issue
that I would like to improve (I'm using Stata 11.2). When I run the
graphs, all of them have the same axis range (starting from week 1 and
finishing on week 260; note: week in my code is represented by SEM).
Is there a way that I can modify, maybe with the definition of a
local, the range to show on each graph? (Please note that my dates are
in the format day/month/year).

More specifically: starting and ending weeks for each one of my graphs are:

isin8    1 1242
isin18  1 685
isin24  1 554
isin29  185 1181
isin220  487 1242
isin221 589 1242
isin222 589 1242
isin224 1 1242
isin225 1 1242
isin251 1 596
isin276 718 1242


gen liq_an=(liq/100)*52
label var liq_an "Liquidez Anual"

local b8 "BCCR c'$'a10 7/2/2002 a 7/2/2012"
local b18 "BCCR	bem 30/9/2004 a 30/9/2009"
local b24 "BCCR	bem 25/3/2006 a 25/3/2009"
local b29 "BCCR bem 28/9/2006 a 28/9/2011"
local b220 "FPTG bpgc$ 18/9/2008 a 18/12/2017"
local b221 "FPTG bpgd$ 18/9/2008 a 18/12/2019"
local b222 "FPTG bpge$ 17/9/2008 a 17/6/2022"
local b224 "FTCB bft13 9/9/2004 a 9/9/2013"
local b225 "FTCB bft15 21/6/2005 a 21/12/2015"
local b251 "G tp$ 27/5/2004 a 27/5/2009"
local b276 "ICE	bic1$ 17/11/2009 a 17/11/2021"

foreach i in 8 225 29 220 18 251 222 221 224 24 276{

#delimit ;

twoway (line sfid sem if isin==`i', clpattern(dash))
(line liq_an sem if isin==`i', yaxis(2)),
ytitle(SFID como % emision, size(medsmall) color(blue) margin(small) axis(1))
ytitle(LIQ_ANUAL, size(medsmall) color(blue) margin(small) axis(2))
ylabel(#10, labsize(medsmall)) xtitle(SEMANA, size(medsmall)
color(blue) margin(small))

xlabel(#15, labsize(medsmall)) title(`b`i'', size(medsmall));
#delimit cr

graph export "D:\data\g_`i'.wmf", replace

Thanks for your comments.

Rodrigo Briceño
SKYPE: rbriceno1087

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index