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

st: RE: RE: RE: hours and minutes help


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: RE: hours and minutes help
Date   Mon, 1 Dec 2003 18:11:02 -0000

As a third and I hope final comment, you
could clearly also go

gen endtime2 = floor(endtime) + 100 * (endtime - floor(endtime)) / 60

My bias here is to regard the -mod(,)- function as so useful
(and so often neglected) that I sometimes use it even when there is
a more direct solution.

For -floor()- read also -int()- so long as all your times
are zero or positive (but not if any is negative).

Nick
n.j.cox@durham.ac.uk

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Nick Cox
> Sent: 01 December 2003 18:00
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: RE: hours and minutes help
>
>
> Correction
>
> > gen endtime2 = floor(endtime) + 100 * mod(endtime,1) / 60
> > gen starttime2 = floor(starttime) + 100 * mod(starttime,1) / 60
>
> Nick
> n.j.cox@durham.ac.uk
>
> > -----Original Message-----
> > From: owner-statalist@hsphsun2.harvard.edu
> > [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Nick Cox
> > Sent: 01 December 2003 17:52
> > To: statalist@hsphsun2.harvard.edu
> > Subject: st: RE: hours and minutes help
> >
> >
> > 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
> > 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