Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: date function


From   "Kabir Chabal" <[email protected]>
To   [email protected]
Subject   Re: st: RE: date function
Date   Fri, 26 Oct 2007 13:27:08 -0700

If the caps doesn't work, try:

gen newdate = subinstr(surgery_date ,"-","",.)
gen numdate = date(newdate, "dmy")

On 10/26/07, Arun Rajamohan <[email protected]> wrote:
>
> Hope it helps...
> gen mydate=date(var1,"DMY")
> DMY must be in capitals
>
>
> . list
>
>      +-------------+
>      |        var1 |
>      |-------------|
>   1. | 20-Jun-2005 |
>   2. | 22-Mar-2005 |
>   3. | 29-Nov-2005 |
>   4. | 18-Apr-2006 |
>   5. | 28-Sep-2004 |
>      +-------------+
>
> . de
>
> Contains data
>   obs:             5
>  vars:             1
>  size:           110 (99.9% of memory free)
> -------------------------------------------------------------------------------
>               storage  display     value
> variable name   type   format      label      variable label
> -------------------------------------------------------------------------------
> var1            str18  %18s
> -------------------------------------------------------------------------------
> Sorted by:
>      Note:  dataset has changed since last saved
>
> . gen mydate=date(var1,"DMY")
>
> . list
>
>      +----------------------+
>      |        var1   mydate |
>      |----------------------|
>   1. | 20-Jun-2005    16607 |
>   2. | 22-Mar-2005    16517 |
>   3. | 29-Nov-2005    16769 |
>   4. | 18-Apr-2006    16909 |
>   5. | 28-Sep-2004    16342 |
>      +----------------------+
>
> . format mydate %d
>
> . list
>
>      +-------------------------+
>      |        var1      mydate |
>      |-------------------------|
>   1. | 20-Jun-2005   20jun2005 |
>   2. | 22-Mar-2005   22mar2005 |
>   3. | 29-Nov-2005   29nov2005 |
>   4. | 18-Apr-2006   18apr2006 |
>   5. | 28-Sep-2004   28sep2004 |
>      +-------------------------+
>
> .
>
>
> On Oct 26, 2007, at 3:00 PM, Tina Hernandez-Boussard wrote:
>
> Sorry, typo, but still get the error:
>
> gen mydate=date( surgery_date, "dmy")
> (737 missing values generated)
>
>
>
>
> On Oct 26, 2007, at 11:55 AM, Nick Cox wrote:
>
>
> mdy? dmy! N
>
> Tina Hernandez-Boussard
>
> Looking for some help converting my string data to a %td.
>
> My date is a str11 as follows:
>
>     | surgery_d~e |
>       |-------------|
>    1. | 20-Jun-2005 |
>    2. | 22-Mar-2005 |
>    3. | 29-Nov-2005 |
>    4. | 18-Apr-2006 |
>    5. | 28-Sep-2004 |
>
> When I try to convert this is a date, gen mydate=date( surgery_date,
> "mdy")
>
> I just get a variable with all values missing.
>
> *
> *   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/
>
> *
> *   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/
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Arun Rajamohan PhD
> Department of Biology
> Room 237, Biological & Geological Sciences Building
> 1151 Richmond Street North
> The University of Western Ontario
> London, ON N6A 5B7 CANADA
>
> Tel: + 1-519-661-2111 ext 80582
> Fax: + 1-519-661-3935
> [email protected]
> http://homepage.mac.com/arunrajmohan/
>
> Other contact numbers:
> Home: 5192047680 / Cell: 5198511553
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
*
*   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