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: Function MONTHS
carmen gamarra <firstname.lastname@example.org>
stata list <email@example.com>
RE: st: Function MONTHS
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?
> Date: Thu, 30 May 2013 14:24:48 +0100
> Subject: Re: st: Function MONTHS
> From: firstname.lastname@example.org
> To: email@example.com
> 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))
> . di mofd(mdy(5,1,2013)) - mofd(mdy(5,30,2013))
> 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.
> On 30 May 2013 14:09, carmen gamarra <firstname.lastname@example.org> 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: