Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: dates


From   Pedro Nakashima <[email protected]>
To   [email protected]
Subject   Re: st: dates
Date   Fri, 7 Oct 2011 15:07:43 -0300

For the days that are in the format like 20080105, I usually transform
them to string, break it with substr() (day, month, year), transform
back to numeric, and then build the date with the function td=mdy().

I don't know a faster way to do that..

2011/10/6 Michael Eisenberg <[email protected]>:
> Colleagues,
>
> I have a list of visit dates for patients.  Unfortunately, the format
> is not constant.
>
> Most are listed with the year, month, day such as 20080105 for Jan 5,
> 2008 but some are listed only with the year and month 200801 for Jan
> 2008.
>
> I attempted to convert them into stata dates with the commands below
> without success.
>
> gen ndate = date(dx_date, "YMD")
> or
> gen ndate = date(dx_date, "CCYYNNDD")
>
> Can stata handle such inconsistent data?
>
> Thanks in advance.
>
> Mike
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index