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

Re: st: dates


From   "Eric G. Wruck" <ewruck@econalytics.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: dates
Date   Wed, 20 Oct 2004 16:09:57 -0400

Hi Rodrigo:

I thought this was going to be pretty simple but failed in my brief attempts to help.  Here's what <help date> had to say:

date() date function

    date(s1,s2) returns the elapsed date corresponding to string s1; string s2 specifies order of month (m), day (d), and year (y) in s1.  y may be preceded by a two-digit default century -- if not, two-digit years produce missing values (.).  The date in s1 can be in almost any format; months can be spelled out or abbreviated (to three characters) or indicated as numbers; blanks and punctuation are allowed.

I thought I understood this & tried:

. input str8 adm_date str8 dis_date

      adm_date   dis_date
  1. 14102003  20102003
  2. 19052003  19052003
  3. 30122003  30122003
  4. 09082003  10082003
  5. 01022003  11022003
  6. 11022003  26022003
  7. 01072003  02072003
  8. end

.
. gen dis_dt2 = date(dis_date,"dmy")
(7 missing values generated)

.
. l

     +-------------------------------+
     | adm_date   dis_date   dis_dt2 |
     |-------------------------------|
  1. | 14102003   20102003         . |
  2. | 19052003   19052003         . |
  3. | 30122003   30122003         . |
  4. | 09082003   10082003         . |
  5. | 01022003   11022003         . |
     |-------------------------------|
  6. | 11022003   26022003         . |
  7. | 01072003   02072003         . |
     +-------------------------------+


But as you can see all the new dates I generated came up missing.  What am I doing wrong?  Or is the help not correct?

Eric


>Dear statalisters. I reviewed the FAQ about how to handle dates and I
>discovered some interesting functions to deal with dates. I have a little
>problem with the dates I have, because the order of mm-dd-yy is not present.
>My dates are dd-mm-yy. I downloaded the "todate" program, and I was capable
>to convert the dates in several files that I have, but other files has this
>different structure. Does anyone knows how to handle with this feature?
>
>Example of my dates:
>
>
>       adm_date  dis_date
>    1. 14102003  20102003
>    2. 19052003  19052003
>    3. 30122003  30122003
>    4. 09082003  10082003
>    5. 01022003  11022003
>    6. 11022003  26022003
>    7. 01072003  02072003
>
>Thanks!
>
>Rodrigo


-- 

===================================================

       Eric G. Wruck
       Econalytics
       2535 Sherwood Road
       Columbus, OH  43209

       ph:      614.231.5034
       cell:    614.327.4182
       fax:     614.231.5039
       eFax:    614.573.6639
       eMail:   ewruck@econalytics.com
       website: http://www.econalytics.com

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