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

RE: st: leap years


From   "Morten Andersen" <[email protected]>
To   <[email protected]>
Subject   RE: st: leap years
Date   Thu, 15 Jan 2004 23:41:29 +0100

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
----------------------------------------------------------------------------

<<winmail.dat>>




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