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: Function MONTHS


From   carmen gamarra <[email protected]>
To   stata list <[email protected]>
Subject   RE: st: Function MONTHS
Date   Thu, 30 May 2013 16:14:21 +0000

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: [email protected]
> To: [email protected]
>
> 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
> [email protected]
>
>
> On 30 May 2013 14:09, carmen gamarra <[email protected]> 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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index