Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Converting string variables into date variables


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Converting string variables into date variables
Date   Tue, 5 Mar 2013 13:30:34 +0000

For future reference, see

 HRF-to-SIF conversion functions

under -help dates and times-.

Nick

On Tue, Mar 5, 2013 at 1:13 PM, Heslin, Margaret
<margaret.heslin@kcl.ac.uk> wrote:

> Thanks so much, Phil. This worked perfectly!!!

Phil Clayton
> You need to specify the century. Try:
> gen DVadmission1 = date(Admission_date_1_12M, "DM20Y")

On 05/03/2013, at 9:31 PM, MargaretHeslin <Margaret.Heslin@kcl.ac.uk> wrote:

>> I have dates in a string format as follows (dmy):
>>
>> 19.09.02
>> 01.12.09 etc
>>
>> I have tried using the following command to convert to date format but
>> the new variable comes up blank. Any suggestions as to what I am doing wrong?
>>
>> DVadmission1 is new new date variable
>> Admission_date_1_12M is the origianl string date variable
>>
>> gen DVadmission1 = date(Admission_date_1_12M, "DMY") format
>> DVadmission1 %td
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index