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: RE: Change string to year and month date
From
George Vega Yon <[email protected]>
To
[email protected]
Subject
Re: st: RE: Change string to year and month date
Date
Fri, 18 Oct 2013 12:32:59 -0300
Dear Matthew,
I guess that what you are trying to do is this:
gen DATE_OF_BIRTH3= mofd(date(DATE_OF_BIRTH2, "YM") )
format DATE_OF_BIRTH3 %tm
Please note that the function -mofd- returns a "monthly date", which
in your case will be 2004m5
Cheers!
George
George Vega Yon
7 647 2552
http://cl.linkedin.com/in/georgevegayon
2013/10/18 Joe Canner <[email protected]>:
> Matthew,
>
> A Stata date variable without a day doesn't make much sense, since a date variable is the number of days since 1/1/1960. Please clarify what it is you intend to do with this variable so that we can give the best advice on how to proceed.
>
> Regards,
> Joe Canner
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of DeMichele, Matthew
> Sent: Friday, October 18, 2013 11:16 AM
> To: [email protected]
> Subject: st: Change string to year and month date
>
> I'm trying to create a date variable using only the year and the month from a string variable formatted as YYYYMM. For example, 200405 = May, 2004. I ran the syntax below, but this results in DAY appearing in the first two columns as "01" such that the example above would be 01May2004.
>
> gen DATE_OF_BIRTH3= date(DATE_OF_BIRTH2, "YM") format DATE_OF_BIRTH3 %td
>
> thank you. Matthew
>
>
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/