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

st: RE: RE: calculating elapsed time [correction]


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: calculating elapsed time [correction]
Date   Mon, 24 Jun 2002 11:05:22 +0100

More haste, less speed: 
> 
> I presume that -date1- and -date2- are Stata daily 
> dates and -time1- and -time2- are string variables. 
> 
> I can't think of a better way than using Stata's 
> supplied functions, e.g. 
> 
> gen str1 Index1 = index(time1,":") 
> 
> gen Time1 = 
> real(substr(time1, 1, index1 - 1)) / 24 + 
> real(substr(time1, 1, index1 + 1)) / (24 * 60) 

gen Time1 = 
real(substr(time1, 1, index1 - 1)) / 24 + 
real(substr(time1, index1 + 1,.)) / (24 * 60) 

> and similarly for the other time variable, after 
> which 
> 
> gen diff = 24 * (date2 - date1) + (Time2 - Time1) 
> 
> Nick 
> n.j.cox@durham.ac.uk 
> 
> 
> *
> *   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/
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index