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

st: RE: hours and minutes help


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: hours and minutes help
Date   Mon, 1 Dec 2003 17:52:21 -0000

I wouldn't use -egenmore- here, as 
an attack from first principles is more direct. 

gen endtime2 = floor(endtime) + mod(endtime,1) / 60 
gen starttime2 = floor(starttime) + mod(starttime,1) / 60 
gen lapse = endtime2 - starttime2 

Nick 
[email protected] 

SURAN, LUCIANA
> 
> I was wondering if any of you know of a method for creating 
> 2 new variables from 1 variable, with 1 of the new 
> variables containing whole numbers and the second new 
> variable containing the numbers after a decimal point.
> 
> I am asking this because I have time data (hours: minutes) 
> in which the hours and minutes are separated by a decimal 
> point instead of a colon (so 6:45 AM is expressed as 6.45, 
> not 6.75). 
> 
> I have 2 variables: starttime and endtime. I need to 
> subtract start-times from the end-times, which I cannot due 
> with the present variable format.  I was thinking of using 
> the "hmm" function that is part of the -egenmore- package.  
> But I need to separate the hours and minutes and this is 
> where I get stuck.

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