Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: on converting dates in stata


From   Phil Clayton <philclayton@internode.on.net>
To   statalist@hsphsun2.harvard.edu
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, rado645-bg@yahoo.de 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index