Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: time series graph xlab/tlab


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: time series graph xlab/tlab
Date   Sat, 11 Feb 2006 22:07:59 -0500

I agree that -help axis_label_options- and the FAQ at
http://www.ats.ucla.edu/stat/stata/faq/grdate.htm
tell you that you can use a datelist of the form
   , tlabel(01apr2001 01jul2001 01oct2001)
or
  , tlabel(1999m1(1)1999m12)
and the example given in the FAQ doesn't work
.  sysuse sp500
. tsset date
. tw tsline high low , tlabel(01apr2001 01jul2001 01oct2001, format(%tdmd) )
invalid ticklist, 01apr2001 must be number
invalid syntax
invalid syntax
r(198);

but that doesn't mean you didn't get a nice informative error message ;)

This does work:
foreach v in 01apr2001 01jul2001 01oct2001 {
  forv i=1/12 {
   if "`: word `i' of `=lower(c(Mons))''"==substr("`v'",3,3) local m=`i'
   }
  local dlist `dlist'
`=mdy(`m',real(substr("`v'",1,2)),real(substr("`v'",6,.)))'
 }
tw tsline high low , tlabel(`dlist', format(%tdmd) )

so numeric dates are fine, and if you want to specify a custom
datelist corresponding to only the observations you have, you can just
use -levels- or levelsof- like so:

gen qdate=quarter(date)
levels qdate, local(qdates)
tw scatter pct qdate, ms(Oh) || tsline pct, tlabel(`qdates', format( %tqcY!Qq))

if I understand your desideratum correctly.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index