how to calculate leap year thru SAS.
In case if i have value say year 2000 its divisible by 4 so its called as leap year.
Likewise i will i have set of years say 2000 to 2012 then how can i do the calculation.
data want ;
do x = 2000 to 2012;
length leap $3;
If mod(x,4)=0 then leap='YES'; /* divisible by 4 */
If mod(x,100)=0 and mod(x,400) ne 0 then leap='NO';
Obs x leap
1 2000 YES
2 2001 no
3 2002 no
4 2003 no
5 2004 YES
6 2005 no
7 2006 no
8 2007 no
9 2008 YES
10 2009 no
11 2010 no
12 2011 no
13 2012 YES
You could begin by creating a data set with just the leap years. Using the trick from @Rick_SAS:
data leap_years(keep=year); length date 8; do year=2000 to 2200; /* MISSING when Feb 29 not a valid date */ date=mdy(2,29,year); if not missing(date) then output; end; run;
Then you could join/merge or exclude dates from your reference data set based on the years that appear in the results of this program. See more explanation in my blog post on this: SAS knows it's a leap year; do you?
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.