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

st: RE: STRING to DATE


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: STRING to DATE
Date   Mon, 8 Mar 2004 18:48:16 -0000

As you are realising, Stata needs to know the century, 
20th, but your syntax is incorrect. 

Something like 

date(dxday, "dmy", 2050) 

should work. 

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

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of 
> Thomas Speidel
> Sent: 08 March 2004 17:53
> To: statalist@hsphsun2.harvard.edu
> Subject: st: STRING to DATE
> 
> 
> Hello,
> 
> I am trying to convert a string variable containing dates into a date
> variable using the DATE command.
> The dates in the string variable "dxday" are in the following format:
> 
> 27-Oct-97
> 19-Sep-99
> 17-Nov-97
> ....
> I used the following command:
> 
> . generate dxday2=date(dxday, "DM19Y")
> (50 missing values generated)
> Obviously, it did not work...
> 
> Does anyone know if there is an easy way to format this type of date
> (DD-MMM-YY)?
> I guess the other way is to modify the data file directly to eliminate
> the dashes, but I wonder if there is a more elegant mehod.

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