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)))
[...]
Thanks for citing me. But this is one instance where I would opt for the
former expression, since we are getting values of 0 or 1 only.