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   David Ashcraft <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Convert to stata date - stored as a numeric variable
Date   Wed, 11 Sep 2013 23:53:30 -0700 (PDT)

Thanks Nick,
I have recoded as per your advice:

gen date2=date(date,"YMD")
generate date1= qofd(date2)
format  date1 %tq

I am getting the following response:

gen date2=date(date,"YMD")
type mismatch

This may be due to the format of date variable. As I mentioned the date variable is numeric not string. what do you recommend?
Regards

David


----- Original Message -----
From: Nick Cox <[email protected]>
To: "[email protected]" <[email protected]>
Cc: 
Sent: Thursday, September 12, 2013 9:34:55 AM
Subject: Re: st: Convert to stata date - stored as a numeric variable

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?searchhttp://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