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 at the end of May, and its replacement, statalist.org is already up and running.


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

RE: st: Function MONTHS


From   carmen gamarra <carmengamarra@hotmail.com>
To   stata list <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Function MONTHS
Date   Thu, 30 May 2013 16:23:33 +0000

thank you Nick,


----------------------------------------
> Date: Thu, 30 May 2013 17:19:11 +0100
> Subject: Re: st: Function MONTHS
> From: njcoxstata@gmail.com
> To: statalist@hsphsun2.harvard.edu
>
> Just as there is a function -mofd()-, there is a function -yofd()-
>
>
> Nick
> njcoxstata@gmail.com
>
>
> On 30 May 2013 17:14, carmen gamarra <carmengamarra@hotmail.com> wrote:
>> thank you Nick,
>> it was just what I needed..
>> but if I would like the newvar returns the number of years, what would be the command?
>>
>>
>>
>> thank you
>>
>>
>> ----------------------------------------
>>> Date: Thu, 30 May 2013 14:24:48 +0100
>>> Subject: Re: st: Function MONTHS
>>> From: njcoxstata@gmail.com
>>> To: statalist@hsphsun2.harvard.edu
>>>
>>> Note that the format of a variable does not define its character.
>>> Indeed I could go
>>>
>>> sysuse auto
>>> format mpg %td
>>>
>>> and Stata would not complain, but nothing would change except a
>>> display format and no spell can change something like -mpg- that is
>>> not a date into something really a date.
>>>
>>> That said, we understand that you have two daily date variables in which case
>>>
>>> mofd(date1) - mofd(date2)
>>>
>>> returns an integer value for the number of months between two dates.
>>> Note that small details disappear and (for example) the number of
>>> months can be a coarse measure of the difference between daily dates
>>>
>>> . di mofd(mdy(5,30,2013)) - mofd(mdy(5,1,2013))
>>> 0
>>>
>>> . di mofd(mdy(5,1,2013)) - mofd(mdy(5,30,2013))
>>> 0
>>>
>>> If you want something else more precise you would need to start with
>>> the difference in days and then proceed from there.
>>>
>>> I don't know what the function you name in Epi Info does exactly.
>>>
>>>
>>> Nick
>>> njcoxstata@gmail.com
>>>
>>>
>>> On 30 May 2013 14:09, carmen gamarra <carmengamarra@hotmail.com> wrote:
>>>> hi people help me
>>>>
>>>> I would like to generate a newvar in my
>>>> stata database to using two oldvar in format
>>>> date (DDMMYYYY), I
>>>> would like the newvar returns the number
>>>> of months (time) between
>>>> <date1> and <date2>.
>>>>
>>>> How can I achieve this function in stata? In epi-info I get that with
>>>> this function:
>>>>
>>>> DEFINE newvar
>>>> ASSIGN newvar =MONTHS(date1, date2)
>>>>
>>>> thank you
>>>> Carmen Gamarra
>>>> *
>>>> * 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/ 		 	   		  
*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index