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

RE: st: Time Format


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Time Format
Date   Fri, 6 May 2005 14:36:20 +0100

Quite so. There is a fuller statement on 
time of day stuff at

http://www.stata.com/statalist/archive/2003-01/msg00592.html

This looks as if it might be rather dated, but my 
guess is that not much has been produced since.  

Nick 
[email protected] 

Svend Juul
 
> Kelly Johnson wrote:
> ---
> Specifically, can I use the mm/dd/yy hh:mm format? (e.g. 
> 04/04/04 09:15
> 04/04/04 09:15
> 04/04/04 09:16
> ---
>  
> You should take a look at the -egenmore- functions. First:
>    ssc install egenmore
>  
> Here is an example using hms(), dhms(), and tod():
>  
> clear
> set obs 1
> generate x = mdy(5,6,1999)
> generate date = x
> format date %d
> egen secs = hms(11 27 15)
> egen datetime = dhms(date 11 27 15)
> generate str sdate = string(date, "%d")
> egen stime = tod(secs)
> generate str sdatetime=sdate+" "+stime
> list , clean
> 
>      x       date   secs   datetime      sdate     stime      
>      sdatetime
> 
>  14370  06may1999  41235  14370.477  06may1999  11:27:15  
> 06may1999 11:27:15

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