Solved
Contributor
Posts: 21

# Leap year

Please help answer the following: I am trying to create a data set that will only contain leap years between two chosen dates.

Thank you a bunch!

Accepted Solutions
Solution
‎04-13-2016 11:14 PM
Super User
Posts: 10,284

## Re: Leap year

``````data test;
do year = 1760 to 2400;
if mod(year,4) = 0 and (mod(year,100) ne 0 or mod(year,400) = 0) then output;
run;
``````
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

All Replies
Super User
Posts: 3,927

## Re: Leap year

I see you have already seen the post that contains this:

``````data leaptest;
do year=1996 to 2016;
date = mdy(02,29,year);
if date ne . then output;
end;
run;
``````
Contributor
Posts: 21

Thank you.

Super User
Posts: 23,786

## Re: Leap year

Are you doing a test or studying for something?

Solution
‎04-13-2016 11:14 PM
Super User
Posts: 10,284

## Re: Leap year

``````data test;
do year = 1760 to 2400;
if mod(year,4) = 0 and (mod(year,100) ne 0 or mod(year,400) = 0) then output;
run;
``````
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 21

## Re: Leap year

Thank you!
🔒 This topic is solved and locked.

Discussion stats
• 5 replies
• 525 views
• 1 like
• 4 in conversation