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: Convert to stata date - stored as a numeric variable


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Convert to stata date - stored as a numeric variable
Date   Thu, 12 Sep 2013 07:34:55 +0100

Your date looks like YMD to me which is what to feed to -date()-. If it is really quarterly you need -qofd()- not -mofd()-.



On 12 Sep 2013, at 06:44, David Ashcraft <[email protected]> wrote:

Hello everyone,

My date variable is stored as numeric (double %8.0g). Date format is 20121231 i.e. YYYYMMDD. Stata does not read it as a date. I have tried the following but it seems that I am missing something.

gen date2=date(date,"MDY")
generate date1= mofd(date2)
format  date1 %tm

Although my data is quarterly but to be on the safer side I am formatting it as %tm.
Any help will be greatly appreciated.


David Ashcraft
PhD Candidate
Bangor University
Bangor, UK.


*
*   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