Re: st: number of dates in x axis

Thanks. My code is a little more complicated than the example so I
didn't want to burden you with it. But I understand your position.
I think the issue has to do with the formatting of the date
variable...I can't seem to get it to work.

Please: I want to see the _exact_ code you typed. No commentary, no
paraphrase, no speculation. If you want to debug your code yourself,
feel free to do so. If you want me to try to debug your code, I am
happy to try, but that means your code, not your thoughts about what
might be wrong with your code.

Sent: 24 May 2011 19:11
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: number of dates in x axis
I tried your code again (this time by pasting it into the do-file
editor instead into the command window) and it worked. But my version
is not working (I still get the invalid label specifier message).
Could it be because my time variable has gaps? Also, how can one setup
the "11" in your for loop without having to make mental calculations
regarding the number of months?
Thanks for the help!
Ana
On May 24, 2011, at 1:31 PM, Nick Cox wrote:

There is relevant material at
Stata 7: How can I get "nice" date labels on a graph?
http://www.stata.com/support/faqs/graphics/nicedate.html
StataCorp have added this annotation:
"Note: This FAQ is relevant for users of releases prior to Stata 8.
For Stata 8 see update from 12 September 2003."
In fact the techniques there do remain useful for some problems.
Here's an example with different data. Here I decide that I want
labels every 2 months from 1 January 2002 to 1 January 2003. I loop
over the dates and put them in a bag, namely a local macro.
sysuse xtline1
xtset person day
forval i = 1(2)11 {
local thisdate = mdy(`i', 1, 2002)
local mydates `mydates' `thisdate'
}
local thisdate = mdy(1,1,2003)
local mydates `mydates' `thisdate'
xtline calories, overlay xlabel(`mydates', format(%d_m_Y) ang(v))
See also