Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Michael Eisenberg <meisenberg713@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: date conversion |
Date | Thu, 26 May 2011 22:10:33 -0500 |
Brilliant!!! On Thu, May 26, 2011 at 8:32 AM, Nick Cox <njcoxstata@gmail.com> wrote: > There is (of course, as they say) a better way: > > gen mydate = string(mydate, "%tdNNDDCCYY") > > Nick > > On Thu, May 26, 2011 at 2:19 PM, Nick Cox <njcoxstata@gmail.com> wrote: >> gen mydate = string(month(date), "%02.0f") + string(day(date), >> "%02.0f") + string(year(date)) >> >> I am assuming your years are all four-digit years, so that you are not >> for example an ancient or medieval historian. >> >> Nick >> >> On Thu, May 26, 2011 at 2:04 PM, Michael Eisenberg >> <meisenberg713@gmail.com> wrote: >>> Colleagues, >>> >>> I need to convert a series of dates in my dataset to a specific format >>> for a collaborator. Currently, they are in the standard stata date >>> format. >>> >>> I need to make them into string variables in the following format: >>> >>> 01051987 which is Jan 5, 1987 >>> 09151973 which is Sept 15, 1973 >>> 12302005 which is Dec 30, 2005 >>> >>> where the month is always 2 characters and the day is also always 2 >>> characters and year is 4 characters. >>> >>> Is this possible? >>> >>> Thank you 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/