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]

Re: st: How do I convert a numeric monthly date into 1jan2000 format for use as an argument to the haver command?


From   Aaron Kirkman <[email protected]>
To   [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 13:45:50 -0500

Nick,

You're exactly right about the haver command. It expects date
constants that match the frequency of the data in question. Running:

    haver use PCUP using "haver\USECON.dat", twithin(2012m1,2013m8) clear

works as expected. Aside: I wasn't expecting the display command to
have any side effects; I forgot to remove it when I reduced my do file
to a minimal working example.

Aaron

On Mon, Aug 5, 2013 at 10:32 AM, Aaron Kirkman <[email protected]> wrote:
> Statalist,
>
> 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?
>
>
> Thank you,
>
> Aaron Kirkman
> *
> *   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/
*
*   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