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: on converting dates in stata


From   Phil Clayton <[email protected]>
To   [email protected]
Subject   Re: st: on converting dates in stata
Date   Sun, 4 Sep 2011 09:36:15 +1000

Not sure if this is the most efficient, but I would:
1. convert it to a string
2. convert the string to a "day" format date using the date() function
3. convert the "day" format date to a "month" format date using the mofd() function

You can do all of the above in a single line. Example:

input date1
200601
200602
200603
200604
end

gen date2=mofd(date(string(date1), "YM"))
format %tm date2
list

Phil

On 04/09/2011, at 6:24 AM, [email protected] wrote:

> 
> Dear all,
> 
> I have monthly dates in excel in the following form: 
> 
> 
> 200601
> 200602
> 200603
> 200604
> ...
> 
> I upload it in Stata and it appears numeric. I have tried a few options with the date command - but I was unsuccessful in converting the variable in the correct formt (mmyyy). 
> 
> 
> Could you help me on that?
> 
> Many thanks,
> Rado
> 
> 
> *
> *   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