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

st: time of day functions


From   baum <[email protected]>
To   StataList <[email protected]>
Subject   st: time of day functions
Date   Tue, 01 Oct 2002 08:08:19 -0400

A thread last week on handling data which contain both date and time led to the creation of three new egen functions, which Nick Cox has kindly included in his omnibus collection -egenmore-.

hms( hh mm ss ) generates an integer variable equal to the number of seconds past midnight for a specific hour, minute, and second, recorded in 24-hour time.

dhms( date hh mm ss ) generates a double variable containing the "Stata date" (days since 01Jan1960), with fractional part equal to the number of seconds past midnight, from integer date variable 'date' (an ordinary %td Stata date) and integer hh, mm, ss. The resulting variable can be used for date/time arithmetic, such as the calculation of time intervals, with resolution better than 1 second.

tod( time ) generates a string variable representing the time of day associated with 'time' number of seconds past midnight; e.g. the variable created by hms().

These functions join a number of time- and date-related functions in Nick's egenmore collection. Additional functions to ease handling of elapsed time intervals are under development.

The hms() and dhms() functions do not operate exactly like those in that other statistical package mentioned by Liz Allred, but they provide equivalent functionality and precision.

Kit
________________________________________________________________________
Christopher F Baum, Boston College Economics, Chestnut Hill MA 02467 USA
[email protected] http://fmwww.bc.edu/ec-v/baum.fac.html
*
* 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