Tuesday, 17 December 2013

SAS Code for Question When a blue moon Occure?

When there are two full moons in a single month, the second is
known as a blue moon. Given that July 9, 1998 is a full moon, and
there are 29 days between full moons, in what months will the next
few blue moons occur?


Solution-- 

data fullmoon;
date = ’09jul98’d;
do i=1 to 500;
month = month(date);
year = year(date);
output;
date = intnx(’day’,date,29);
end;
run;


Now we can use the put function to create a variable with the full month name and the year.

data bluemoon;
set fullmoon;
by year month;
if last.month and not first.month then do;
when = put(date,monname.) || ", " || put(date,year.);
output;
end;
run;
proc print data=bluemoon noobs;
var when;
run;   

No comments:

Post a Comment