Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Date + Time of Day


From   Joseph Coveney <[email protected]>
To   Statalist <[email protected]>
Subject   Re: st: Date + Time of Day
Date   Wed, 15 Jun 2005 23:14:52 +0900

Eric G. Wruck wrote:

I have an Excel spreadsheet which includes a date column & dates are 
in the following form:

11/14/2000  16:27:00

That is, the date includes the time of day.  I've searched my Stata 9 
manuals & all I can find on time is part of c(return) where one can 
use c(current_time) but this doesn't seem relevant/helpful.

Is there a format that includes time as part of a date, or do I have 
to parse this field out & create my own separate time variable?  What 
do others do to handle this?

--------------------------------------------------------------------------------

Take a look at -odbc load- (-help odbc-).  If your operating system supports 
ODBC, then the -datestring- option to -odbc load- allows you to input date-time 
data formats from ODBC sources into Stata as strings that include both date and 
time.  Microsoft provides an Excel ODBC driver that you can use with Stata.

Of course, it'll arrive in Stata as a string variable and, because Stata does 
not have a date-time data-type, if you want to do arithmetic on the values, 
then you'll still need to parse them into separate date and time variables.  
There are functions that facilitate this--Nick Cox wrote an FAQ that he posted 
on the List some time ago that surveys time functions in Stata:  
www.stata.com/statalist/archive/2003-01/msg00592.html . . . highly recommended.

Joseph Coveney

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index