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: date conversion
From
Muhammad Anees <[email protected]>
To
[email protected]
Subject
Re: st: date conversion
Date
Fri, 27 May 2011 08:40:30 +0500
Sorry to post might be not in the right place but my question somehow
related to the conversion of dates too. I have date in the format
1/1/2008 and it is in the string format. When I tsset my data using
the string variable it is not working as usual. Now I have encoded my
date variable using encode date, gen(day) which generates new day
variables but when I explore the data all the day variable has been
re-ordered and what reasons works behind it. Also how can I expect to
have to have both date and day side by side and no ordering to occure
when I convert date to day or otherwise.
On 26 May 2011 18:32, Nick Cox <[email protected]> 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 <[email protected]> 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
>> <[email protected]> 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/
>
--
---
Best,
---------------
Anees
*
* 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/