/**********************************************************************/


data leaps;
   any=mdy(2,29,1994);
   mult4=mdy(2,29,1996);
   mult100=mdy(2,29,1900);
   mult400=mdy(2,29,2000);
   mult4000=mdy(2,29,8000);
run;

proc print data=leaps noobs width=min;
   title 'Is It a Leap Year?';
   format _all_ worddate18.;
run;


/**********************************************************************/


data history;
   moonwalk=weekday('20jul1969'd);
   veday=weekday('08may1945'd);
   flight=weekday('17dec1903'd);
   usa200th=weekday('04jul1976'd);
   bigcrash=weekday('29oct1929'd);
   bullrun1=weekday('21jul1861'd);
run;

proc print data=history noobs;
   title 'Days of the Week for Historical Dates';
run;


/**********************************************************************/


data endpoint;
   input start date9. @11 finish date9.;
   cards;
01jan1900 31dec1999
;

data mylib.randate(drop=i);
   set endpoint;
   range=finish-start;
   possible=range+1;
   do i=1 to 20;
      select=int(ranuni(31636)*possible)+start;
      output;
   end;
run;

proc print data=mylib.randate;
   title 'Twenty Randomly Generated Dates in 1900s';
   format select worddate18.;
run;


/**********************************************************************/


data answers(drop=start finish range possible);
   set mylib.randate;
   day=weekday(select);
run;

proc print data=answers;
   title 'Days of Randomly Generated Dates';
   format select weekdate29.;
run;


/**********************************************************************/