Macro dtday

From sasCommunity
Jump to: navigation, search

Macros_by_Ian_Whitlock

%macro dtday ( start = 01feb96 );
 
data fmtdata (keep = fmtname start end label );
     retain fmtname 'dtday' 
            start   "&start:00:00:00"dt;
 
do day = 1 to 31
   while (datepart(start) < intnx('month',"&start"d,1));
   end   = start + 86399;
   label = put(day,2.);
   output fmtdata;
   start = end + 1;
   end;
run;
 
proc format cntlin = fmtdata;
run;
%mend dtday;

harvesting and code polishing by:

--macro maven == the radical programmer 14:57, 23 May 2012 (EDT)