Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: leap years


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: leap years
Date   Fri, 16 Jan 2004 16:20:48 -0000

OK. But this is (in practice) equivalent 
to a part of my posting you do not copy 
here. 

Nick 
[email protected] 

> -----Original Message-----
> From: Morten Andersen 
> [mailto:[email protected]]On
> Behalf Of Morten Andersen
> Sent: 15 January 2004 22:41
> To: [email protected]
> Subject: RE: st: leap years
> 
> 
> At 06:30 PM 1/15/2004 +0000, Nick Cox wrote:
> >2004 is a leap year. This raises a small Stata problem,
> >how to determine if a year is a leap year using Stata
> >syntax.
> >
> >[...]
> >
> >In Stata: suppose -year- is a variable. An indicator
> >1 for leap year and 0 otherwise is then
> >given by
> >
> >(mod(year,4) == 0 & mod(year,100) != 0) | mod(year,400) == 0
> >
> >as -mod(,)- provides the remainder left over from division.
> >
> >The nested -cond()- solution, to please David Kantor, is
> >
> >         cond(mod(year,400) == 0, 1,
> >           cond(mod(year,100) == 0, 0,
> >           cond(mod(year,4)   == 0, 1,
> >           0)))
> >
> >[...]
> 
> What about
> 
> mdy(2,29,year) != . 
> 
> ?
> 
> Regards,
> 
> Morten Andersen
> 
> ------------------------------------------------------------
> ----------------
> Morten Andersen, MD, PhD               Research Unit of 
> General Practice
> Senior Researcher                      University of 
> Southern Denmark
> Phone   +45 6550 3791                  Winsloewparken 19
> Fax     +45 6591 6089                  DK-5000 Odense C
> E-mail  [email protected]        Denmark
> ------------------------------------------------------------
> ----------------
> 

<<attachment: winmail.dat>>




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index