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

RE: st: Time to run a program


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Time to run a program
Date   Wed, 12 May 2004 17:51:28 +0100

... which reminds me also that F. Zimmerman has 
already done something like this in his -elapse-. 

. search elapse 

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of David Kantor
> Sent: 12 May 2004 17:40
> To: [email protected]
> Subject: Re: st: Time to run a program
> 
> 
> At 06:06 PM 5/12/2004 +0200, Jean-Benoit Hardouin wrote:
> >this command permet to display the date/time, but don't 
> solve my problem 
> >(Perhaps I have not see all the subtleties of this command).
> >
> >My problem is to compute the time between the beginning and 
> the end of the 
> >running of a program.
> >
> >Thank you for your help.
> >[...]
> 
> 
> As you mentioned in your earlier message, you can take the time using 
> $S_TIME (or, equivalently, c(current_time) ).
> 
> I'm usually content to just display them and mentally take the 
> difference.  But it is possible to automate this.  You would need to 
> textually take apart the time value into its components, and 
> convert to 
> numbers.  Thus:
>   local time1 = c(current_time)
>   scalar hour1 = real(substr("`time1'", 1, 2))
>   scalar min1 = real(substr("`time1'", 4, 2))
>   scalar sec1 = real(substr("`time1'", 7, 2))
> 
> Do the same for another moment in time.
> 
> Then you need to subtract them.  The easiest way would be to 
> convert them 
> into seconds (within the day): hour1 * 3600 + min1 * 60 + sec1.
> 
> Of course, there are complications if the run spans different 
> days.  I 
> leave that to you.
> 

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