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]

st: RE: RE: RE: Date conversion question


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: RE: RE: Date conversion question
Date   Thu, 10 Mar 2011 14:45:26 +0000

I withdrew my incorrect diagnosis about a hour ago. Sorry you were misled. 

-year(dofc())- does indeed give implausible results for your times because they were never date-times in the first place. 

Another way of seeing that I was wrong was that you knew that your data were not in milliseconds, as I was supposing. 

Nick 
[email protected] 

Amy Dunbar

Thank you, Nick and Scott. Although I have a better understanding of how to change the format of the date so it makes sense to me, I still struggle with the detail in the -help dates and times-. Recall that my date variable is "rssd9999."

I used Scott's code as follows:
. gen double mydate = date(string(rssd9999,"%12.0g"), "YMD") 
. gen double year = year(mydate)
. gen double month = month(mydate)

I was unsuccessful when I tried to use the dofc command.
When I tried the following, my year was always 1960
. format rssd9999 %td  //I tried %tc, %td, and %ty - same result
. gen double year =year(dofc(rssd9999))

When I tried the following, my year was always 0.
. format rssd9999 %tc
. gen double year = dofc(rssd9999)


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index