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]

st: do file for graphs


From   Rodrigo Briceño <[email protected]>
To   [email protected]
Subject   st: do file for graphs
Date   Tue, 20 Nov 2012 11:18:36 -0600

Dear Stata users. I made a do file in order to produce a series of 11
graphs. The data file I have is in panel format. What I want is that
each graph has its own X-axis scale, depending on the dates of start
and end that I specified on locals "tin". Could anybody please
illustrate myself what I'm possibly doing wrong? I'm using stata 11.2
and after several trials the error I got after getting 3 graphs (with
no scale changes) is "invalid syntax". Thanks for your help

My code:

use "D:\data\panel355s.dta", clear
xtset isin t2

local b8 "CRBCCR0B0104"
local b18 "CRBCCR0B2985"
local b24 "CRBCCR0B3199"
local b29 "CRBCCR0B3249"
local b220 "CRFPTG0B0013"
local b221 "CRFPTG0B0021"
local b222 "CRFPTG0B0039"
local b224 "CRFTCB0B0038"
local b225 "CRG0000B35G3"
local b251 "CRG0000B71F0"
local b276 "CRICE00B0051"

local tin8 "tin(02jan2007, 22dec2011)"
local tin18 "tin(02jan2007, 24sep2009)"
local tin24 "tin(02jan2007, 20mar2009)"
local tin29 "tin(20set2007, 28set2011)"
local tin220 "tin(10dec2008, 22dec2011)"
local tin221 "tin(13may2009, 22dec2011)"
local tin222 "tin(13may2009, 22dec2011)"
local tin224 "tin(02jan2007, 22dec2011)"
local tin225 "tin(02jan2007, 22dec2011)"
local tin251 "tin(02jan2007, 27may2009)"
local tin276 "tin(13nov2009, 22dec2011)"

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

preserve
keep if isin == `i'
#delimit ;

twoway (line sfid sem if `tin`i'', clpattern(dash))
(line liq_an sem, 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
restore

graph export "D:\data\g_`i'.wmf", 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