Resources

Fiscal Month Example

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: intex02.sas
 Description: Example program from SAS/ETS User's Guide,
              Date Intervals, Formats, and Functions
       Title: Fiscal Month Example
     Product: SAS/ETS Software
        Keys: time intervals, time functions
        PROC: interval functions
       Notes:

--------------------------------------------------------------*/

options intervalds=(FiscalMonth=FMDS);
data FMDS(keep=BEGIN SEASON);
   start = '10JAN1999'D;
   stop  = '10JAN2001'D;
   nmonths = INTCK('MONTH',start,stop);
   do i=0 to nmonths;
      BEGIN = INTNX('MONTH',start,i,'S');
      SEASON = MONTH(BEGIN);
      output;
   end;
   format BEGIN DATE.;
run;

data sales(keep=DATE sales);
   do date = '01JAN2000'D to '31DEC2000'D;
      month = MONTH(date);
      dayofmonth = DAY(date);
      sales = 0;
      if ( dayofmonth lt 10 ) then sales = month/9;
      output;
   end;
   format date monyy.;
run;

proc timeseries data=sales out=dataInFiscalMonths;
   id DATE interval=FiscalMonth accumulate=total;
   var sales;
run;

proc timeseries data=sales out=dataInStdMonths;
   id DATE interval=Month accumulate=total;
   var sales;
run;

data compare;
     merge dataInFiscalMonths(rename=(sales=FM_sales))
           dataInStdMonths(rename=(sales=SM_sales));
     by DATE;
run;

title 'Standard Monthly Data vs. Fiscal Month Data';
proc print data=compare;
run;