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: date-time conversion problems [was: RE: RE: statalist-digest V4 #4311]


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: date-time conversion problems [was: RE: RE: statalist-digest V4 #4311]
Date   Fri, 21 Oct 2011 15:24:00 +0100

. help dates and times 

bears this warning: 

		                  DO NOT FORGET                                 |
                  %tc and %tC values MUST BE stored as doubles. 
                  Doing so is your responsibility, not Stata's. 

See for a reminder from just last Monday:

http://www.stata.com/statalist/archive/2011-10/msg00686.html

So, try that first. 

gen double time2 = ... 

Nick 
[email protected] 

Mark McCann

                I'm at a loss as to what's happening here. I have checked the help files and statalist, but I just can't make sense of this. My time variable appears to be reading seconds incorrectly, this happened before I added a dummy ":00" seconds onto the string variable, and after (as below). Any ideas on what is happening? I'm using Stata 11 on Windows


gen space=" "
gen seconds=":00"
egen time1=concat(date space time seconds)
gen time2=clock(time1,"DMYhms")
format time2 %tc


Here are the results for the first observation, I've fixed these to stop formatting problems

Date 01/05/2011   
Time 00:01       
Seconds :00   
Time1 [The used variable] 01/05/2011 00:01:00   


Time2 [The final variable] 01may2011 00:00:28 


Similar errors occur throughout, in some cases rounding up or down would give the wrong result so I can't use a quick fix and ignore the problem!


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