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
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Function MONTHS
Date
Thu, 30 May 2013 17:29:14 +0100
Anyone interested in computing differences in months, years, ... from
daily dates ight like also to note
. ssc desc personage
-----------------------------------------------------------------------------------------
package personage from http://fmwww.bc.edu/repec/bocode/p
-----------------------------------------------------------------------------------------
TITLE
'PERSONAGE': module to calculate people's ages or similar daily
date differences
DESCRIPTION/AUTHOR(S)
personage is designed in the first instance for calculations of
people's ages from data on their birth date and some "current"
daily date. A new variable is generated containing age in
(completed) years; and new variables may be generated containing
(1) time since last birthday in days and (2) length of the
current year. Nothing stops application to any problem requiring
completed years, and optionally extra days, as a representation
of the difference between two daily dates.
KW: age
KW: dates
Requires: Stata version 8.2
Distribution-Date: 20130205
Nick
[email protected]
On 30 May 2013 17:23, carmen gamarra <[email protected]> wrote:
> thank you Nick,
>
>
> ----------------------------------------
>> Date: Thu, 30 May 2013 17:19:11 +0100
>> Subject: Re: st: Function MONTHS
>> From: [email protected]
>> To: [email protected]
>>
>> Just as there is a function -mofd()-, there is a function -yofd()-
>>
>>
>> Nick
>> [email protected]
>>
>>
>> On 30 May 2013 17:14, carmen gamarra <[email protected]> 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: [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/
>> *
>> * 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/