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

st: RE: date functions


From   "Huiber Gabi (nat1gxh)" <nat1gxh@ups.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: RE: date functions
Date   Wed, 16 Apr 2003 16:02:15 -0400

I get my date variables in the format "mm/dd/yy 00:00:00" because they
include a default exact time in hours:minutes:seconds. I turn them into
Stata elapsed date format as follows:
 
rename mydate t
gen q=index(t," ")
gen str12 dateq=trim(substr(t,1,q))
 
** the line above will keep only the mm/dd/yy part of the original mydate

gen mydate=date(dateq,"md20y")

This assumes that there are no dates earlier than 2000. You can always
adjust for that. One way would be:
 
gen x=year(mydate)
replace mydate=date(dateq,"md19y") if x>2003

drop q t dateq x
 
If there is an easier way, I'm curious.
 
Gabi

-----Original Message-----
From: Higdon, Keith M. [mailto:khigdon@sedgwickcms.com]
Sent: Wednesday, April 16, 2003 3:43 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: date functions



Is there a way to use the gen edate function to transform numerous date
fields into elapsed dates with different variable names?  Thank you.

 

Keith 



  _____  

DISCLAIMER:
The information transmitted is intended only for the person or entity to
which it is addressed
and may contain confidential and/or privileged material. Any
review,retransmission, dissemination
or other use of, or taking of any action in reliance upon, this information
by persons or entities
other than the intended recipient is prohibited. If you received this in
error, please contact
the sender and delete the material from any computer. 



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