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: How do I convert a numeric monthly date into 1jan2000 format for use as an argument to the haver command?
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: How do I convert a numeric monthly date into 1jan2000 format for use as an argument to the haver command?
Date
Mon, 5 Aug 2013 17:54:25 +0100
I have never used -haver- but I know something about dates.
If the data you are importing are monthly I would expect -twithin()-
to expect monthly dates.
Your macro manipulations don't seem the issue here but note that
di %td `month'
does one thing and one thing only: it -display-s the contents of the
local macro -month- according to the format specified. It does not
convert anything to anything else, or have side-effects. What you seem
to be seeking is more likely
local month : di %td dofm(643)
which would place the string "01aug2013" in the local macro -month-.
However, as said, that can't be what -haver- seeks, as direct input failed.
Nick
[email protected]
On 5 August 2013 16:32, Aaron Kirkman <[email protected]> wrote:
> I have a numeric monthly date stored in a macro, i.e.
>
> loc currentmonth 643
>
> for August 2013. Is there a way to convert this month into the format
> 01aug2013 for use with the haver command's "twithin" or "tin" option?
> Currently, I have this code:
>
> loc monthn 643
> loc month `=dofm(`monthn')'
> di %td `month'
> haver use PCUP using "haver\USECON.dat", twithin(01jan2013,`month') clear
>
> but this returns an r(198) invalid syntax error. If I follow the
> documentation and omit the macro:
>
> haver use PCUP using "haver\USECON.dat", twithin(01jan2013,01aug2013) clear
>
> I get the same error. The command works properly if I omit the "twithin" option:
>
> haver use PCUP using "haver\USECON.dat", clear
>
> What is the proper date format for the haver command, and how do I
> convert this numeric date into that format?
*
* 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/