Previous Topic: 4.7.2.2 Thirteen Month Calendar Modifications

Next Topic: 4.7.2.4 Whether to Use DWMY12 or DWMYWK1 Date Macros

4.7.2.3 Calendar Modifications for 445/454/544 Calendars


If your organization needs to operate CA MICS on a calendar
system with each calendar quarter composed of a 4 week month,
4 week month, and 5 week month (or 4-5-4 or 5-4-4), consider
the following addition to the information provided for
Gregorian-based calendar installation.

Note:  The CA MICS Accounting and Chargeback Product includes
       facilities for defining a unique accounting calendar
       separate from the global CA MICS calendar definitions.
       This capability is designed to help you meet your
       requirements for chargeback and accounting relative to
       your company's fiscal calendar while continuing to use
       the standard 12-month calendar for the majority of
       your CA MICS information.  Please refer to the CA MICS
       Accounting and Chargeback Guide for more information
       before altering the global CA MICS calendar.

The topics that are relevant when dealing with this type of
special accounting calendar are:

    1.  When does the first day of the accounting week begin?
        (e.g., Sunday, Monday etc.)

    2.  When does each accounting year begin and end? It must
        begin at the start of a week and the start of
        accounting month 1.

    3.  Which accounting year has 53 weeks in it? Generally,
        there are 52 weeks in a year and then every 6th year
        there is a 53 week year to adjust for the extra days.

    4.  Which month within the 53 week year will have the 5th
        week? The normal pattern of either 4-4-5, 4-5-4, or
        5-4-4 weeks in a quarter of a year must have an extra
        week in one designated month.

    5.  Which years have starting dates in the same year as
        the accounting year (e.g., starting date of 02JAN01
        is in accounting year 2001).

    6.  Which pattern fits your accounting calendar? The
        patterns are either 4-4-5, 4-5-4, or 5-4-4.

    7.  How many years of data do you need to keep for
        CA MICS?

After you have resolved the previous questions, the
implementation strategy within CA MICS can be addressed.
A.  CODE THE COMPLEX-LEVEL CPLXDEF OR UNIT-LEVEL SITE
    PARAMETER MEMBER

    If you want to define a global, complex-level special
    calendar, then code the 13MONTHYEAR parameter in
    sharedprefix.MICS.PARMS(CPLXDEF) as described below and
    run sharedprefix.MICS.CNTL(CPLXGEN).  The new
    complex-level special calendar will take effect when you
    execute the unit-level BASPGEN job.

    Otherwise, specify the 13MONTHYEAR parameter in
    prefix.MICS.PARMS(SITE) to restrict the special calendar
    to a specific unit.

    Code the parameter as,
        '13MONTHYEAR NO #DWMY=#memname'
    where memname is your modified member.  See PIOM,
    Sections 2.3.1.8 and 2.3.2.4.  'memname' must exist as a
    #memname version and as a $memname version if memname
    begins with the letters DWMY.  BASPGEN is coded to
    include #DWMYxxx from the #BASMSTR module it generates
    and include $DWMYxxx from the $BASMSTR module it
    generates.  If memname does not begin with DWMY, BASPGEN
    will generate code to include #memname from the #BASMSTR
    module and from the $BASMSTR module.

    For example, memname might be called DWMY445; therefore a
    # version would exist called #DWMY445 which contains
    macro definitions written in SAS Macro statements and a $
    version, $DWMY445, containing corresponding macros
    written in SAS Macro language would also exist.  (You
    will see later how to code changes for both members).
B.  CODE THE CHANGES FOR #memname AND $memname

    For $memname, modify sharedprefix.MICS.SOURCE($DWMY445).
    '$memname' contains the date macros written with SAS
    Macro language.

    For each year that you need to specify to CA MICS, code a
    WHEN statement like the ones shown below in the SETYRST
    macro.  Provide the start date, the ending date, and the
    value to set the variable YRSTART to, which is the start
    date again.  Be careful that each start date begins on
    the first of your defined week and the start of
    accounting month 1.

    %MACRO SETYRST; ENDDT = DATEPART(ENDTS);

      %* MODIFY THE FOLLOWING CODE AS NECESSARY.  ;
      %* INDICATE THE START      ;
      %* OF YEAR AND THE END OF THE SAME YEAR IN ;
      %* THE FOLLOWING SET OF     ;
      %* STATEMENTS. ;

      SELECT;
        WHEN ('02JAN84'D LE ENDDT LE '30DEC84'D )
             YRSTART='02JAN84'D;
        WHEN ('31DEC84'D LE ENDDT LE '29DEC85'D )
             YRSTART='31DEC84'D;
        WHEN ('30DEC85'D LE ENDDT LE '28DEC86'D )
             YRSTART='30DEC85'D;
        WHEN ('29DEC86'D LE ENDDT LE '27DEC97'D )
             YRSTART='29DEC86'D;
        WHEN ('28DEC87'D LE ENDDT LE '25DEC88'D )
             YRSTART='28DEC87'D;
        WHEN ('26DEC88'D LE ENDDT LE '31DEC89'D )
             YRSTART='26DEC88'D;
        WHEN ('01JAN90'D LE ENDDT LE '30DEC90'D )
             YRSTART='01JAN90'D;
        WHEN ('31DEC90'D LE ENDDT LE '29DEC91'D )
             YRSTART='31DEC90'D;
        OTHERWISE DO;
          CALL MICSLOG('BAS00473');
          ABORT ABEND 510;
        END;
      END;
    %MEND SETYRST;

The Macro language statements are:

    %MACRO YEAR;
      %SETYRST;

      SELECT (YRSTART);
        WHEN ('02JAN84'D) YEAR = YEAR(YRSTART) - 1900;
        WHEN ('01JAN90'D) YEAR = YEAR(YRSTART) - 1900;
        OTHERWISE YEAR = YEAR(YRSTART) - 1899;
      END;
    %MEND YEAR;

    As shown above, the year is identified by its start date.
    The amount of 1900 is subtracted from years coded here.
    This results in the accounting year being correctly
    identified for those years in which the start date is in
    the same year as the accounting year.

    Using the example of a fiscal year beginning on January
    2, 1984 as coded above, let's see how this works.  If we
    call this fiscal year 1984, we would want to subtract
    1900 because the year of our start date--1984--minus 1900
    yields 84.  If we decide to call the fiscal year 1985, we
    would subtract 1899 because the start date year of 1984
    minus 1899 yields 85.

    Since our logic is designed to do this as the normal
    course of action, we would have omitted 02JAN84 from the
    SELECT statement.  The real intent here is to arrive at a
    value which, when subtracted from the year of the start
    date of each fiscal year that we have specified to
    CA MICS, will result in the year that we intend to have
    the fiscal year called.


The code shown below pertains to defining which year will
have 53 weeks.

    %MACRO MONTH;
      %YEAR;
      TEMPDAY = ENDDT + 1 - YRSTART;

      %* MODIFY THE FOLLOWING CODE AS  NECESSARY.  EACH  53;
      %* WEEK  YEAR  MUST  BE  CODED  IN  THIS  CHECK.  THE;
      %* SPECIAL FORMAT THAT USES 371 DAYS WILL BE USED FOR;
      %* A 53 WEEK YEAR.  THE EXAMPLE SHOWS 1989 AS THE  53;
      %* WEEK YEAR ;

      SELECT (YEAR);
        WHEN (89) MTHDAYS=PUT(TEMPDAY,YR455WK.);
                  %* 1989 IS 53-WEEK YEAR  ;
        OTHERWISE MTHDAYS=PUT(TEMPDAY,YR445WK.);
      END;
      MONTH = INPUT(SUBSTR(MTHDAYS,1,2),2.);
    %MEND MONTH;

    Generally, there are 52 weeks in a year and then every
    6th year there is a 53 week year to adjust for the extra
    days.  This implementation in CA MICS consists of
    creating two formats in the sharedprefix.MICS.LOAD
    library to be used by the exit coding.  The first format,
    labeled YR445WK, is to be used with the 52 week year.
    The second format, labeled YR455WK, is to be used with
    the 53 week year.  In our example code above, 1989 is a
    53 week year and will be formatted using the 53 week
    format YR455WK.  The YR445WK and YR455WK formats are
    defined in Step C, below.

    The code shown below uses the YR445WK and YR455WK formats
    in a way similar to the MONTH macro logic.  The ordinal
    number of a day within a year defines the start day of
    the month in which the day lies.  The difference between
    ordinal year day and month start day is DAY (of month).

    %MACRO DAY;
      %YEAR;
      TEMPDAY = ENDDT + 1 - YRSTART;

      %* MODIFY THE FOLLOWING CODE AS NECESSARY.  EACH 53;
      %* WEEK  YEAR  MUST  BE  CODED  IN THIS CHECK.  THE;
      %* SPECIAL FORMAT THAT USES 371 DAYS WILL  BE  USED;
      %* FOR  A  53 WEEK YEAR.  THE EXAMPLE SHOWS 1989 AS;
      %* THE 53 WEEK YEAR;

      SELECT (YEAR);
        WHEN (89) MTHDAYS=PUT(TEMPDAY,YR455WK.);
                 %* 1989 IS 53-WEEK YEAR  ;
        OTHERWISE MTHDAYS=PUT(TEMPDAY,YR445WK.);
      END;
      DAY = TEMPDAY - INPUT(SUBSTR(MTHDAYS,3,3),3.);
    %MEND DAY;

    EXAMPLE
    Below is an example of the coded $DWMY445 that uses a 4-
    4-5 accounting calendar.  The first year starts on
    02JAN84 and ends on 30DEC84.  Each week begins on Monday.
    The accounting year that has 53 weeks is 1989.  The 11th
    month has the extra week in the 53 week year.  The two
    years in the sample that begin in the same year as the
    accounting year have the starting dates of 02JAN84 and
    01JAN90.

    %LET WKSTART=2;

    %LET MONTHDF=12;

    %MACRO SETYRST;
      ENDDT = DATEPART(ENDTS);

      SELECT;
        WHEN ('02JAN84'D LE ENDDT LE '30DEC84'D )
             YRSTART='02JAN84'D;
        WHEN ('31DEC84'D LE ENDDT LE '29DEC85'D )
             YRSTART='31DEC84'D;
        WHEN ('30DEC85'D LE ENDDT LE '28DEC86'D )
             YRSTART='30DEC85'D;
        WHEN ('29DEC86'D LE ENDDT LE '27DEC97'D )
             YRSTART='29DEC86'D;
        WHEN ('28DEC87'D LE ENDDT LE '25DEC88'D )
             YRSTART='28DEC87'D;
        WHEN ('26DEC88'D LE ENDDT LE '31DEC89'D )
             YRSTART='26DEC88'D;
        WHEN ('01JAN90'D LE ENDDT LE '30DEC90'D )
             YRSTART='01JAN90'D;
        WHEN ('31DEC90'D LE ENDDT LE '29DEC91'D )
             YRSTART='31DEC90'D;
        OTHERWISE DO;
          CALL MICSLOG('BAS00473');
          ABORT ABEND 510;
        END;
      END;
    %MEND SETYRST;

    %MACRO YEAR;
      %SETYRST;
      SELECT (YRSTART);
        WHEN ('02JAN84'D) YEAR = YEAR(YRSTART) - 1900;
        WHEN ('01JAN90'D) YEAR = YEAR(YRSTART) - 1900;
        OTHERWISE YEAR = YEAR(YRSTART) - 1899;
      END;
    %MEND YEAR;

    %MACRO MONTH;
      %YEAR;
      TEMPDAY = ENDDT + 1 - YRSTART;
      SELECT (YEAR);
        WHEN (89) MTHDAYS=PUT(TEMPDAY,YR455WK.);
                  %* 1989 IS 53-WEEK YEAR  ;
        OTHERWISE MTHDAYS=PUT(TEMPDAY,YR445WK.);
      END;
      MONTH = INPUT(SUBSTR(MTHDAYS,1,2),2.);
    %MEND MONTH;

    %MACRO DAY;
      %YEAR;
      TEMPDAY = ENDDT + 1 - YRSTART;
      SELECT (YEAR);
        WHEN (89) MTHDAYS=PUT(TEMPDAY,YR455WK.);
                  %* 1989 IS 53-WEEK YEAR  ;
        OTHERWISE MTHDAYS=PUT(TEMPDAY,YR445WK.);
      END;
      DAY = TEMPDAY - INPUT(SUBSTR(MTHDAYS,3,3),3.);
    %MEND DAY;

    For #memname (which contains the date macros written with
    SAS Macro statements), the modifications to the default
    member sharedprefix.MICS.SOURCE($DWMY445) you have just
    completed would need to be copied to
    sharedprefix.MICS.SOURCE(#DWMY445) and modified to the
    SAS Macro statement style.

    Below is an example of the coded #DWMY445 that is the SAS
    Macro statement version of the $DWMY445 member we coded
    in the earlier example.

    MACRO _WKSTART 2 %

    MACRO _MONTHDF 12 %

    MACRO _SETYRST;
      ENDDT = DATEPART(ENDTS);
      SELECT;
        WHEN ('02JAN84'D LE ENDDT LE '30DEC84'D )
             YRSTART='02JAN84'D;
        WHEN ('31DEC84'D LE ENDDT LE '29DEC85'D )
             YRSTART='31DEC84'D;
        WHEN ('30DEC85'D LE ENDDT LE '28DEC86'D )
             YRSTART='30DEC85'D;
        WHEN ('29DEC86'D LE ENDDT LE '27DEC97'D )
             YRSTART='29DEC86'D;
        WHEN ('28DEC87'D LE ENDDT LE '25DEC88'D )
             YRSTART='28DEC87'D;
        WHEN ('26DEC88'D LE ENDDT LE '31DEC89'D )
             YRSTART='26DEC88'D;
        WHEN ('01JAN90'D LE ENDDT LE '30DEC90'D )
             YRSTART='01JAN90'D;
        WHEN ('31DEC90'D LE ENDDT LE '29DEC91'D )
             YRSTART='31DEC90'D;
        OTHERWISE DO;
          CALL MICSLOG('BAS00473');
          ABORT ABEND 510;
        END;
      END;

    MACRO _YEAR
      _SETYRST
      SELECT (YRSTART);
        WHEN ('02JAN84'D) YEAR = YEAR(YRSTART) - 1900;
        WHEN ('01JAN90'D) YEAR = YEAR(YRSTART) - 1900;
        OTHERWISE YEAR = YEAR(YRSTART) - 1899;
      END;

    MACRO _MONTH
      _YEAR
      TEMPDAY = ENDDT + 1 - YRSTART;
      SELECT (YEAR);
        WHEN (89) MTHDAYS=PUT(TEMPDAY,YR455WK.);
                  %* 1989 IS 53-WEEK YEAR  ;
        OTHERWISE MTHDAYS=PUT(TEMPDAY,YR445WK.);
      END;
      MONTH = INPUT(SUBSTR(MTHDAYS,1,2),2.);

    MACRO _DAY
      _YEAR
      TEMPDAY = ENDDT + 1 - YRSTART;
      SELECT (YEAR);
        WHEN (89) MTHDAYS=PUT(TEMPDAY,YR455WK.);
                  %* 1989 IS 53-WEEK YEAR  ;
        OTHERWISE MTHDAYS=PUT(TEMPDAY,YR445WK.);
      END;
      DAY = TEMPDAY - INPUT(SUBSTR(MTHDAYS,3,3),3.);
    %
C.  GENERATING AND LOADING THE YRWK445 AND YR455WK FORMATS

    The implementation in CA MICS consists of creating two
    PROC FORMATs into the sharedprefix.MICS.MCOLIB library to
    be used by the exit coding.  The two PROC FORMATs that
    are provided use a 4-4-5 accounting calendar.  The first
    format, labeled YR445WK, is to be used with the 52 week
    year.  The second format, labeled YR455WK, is to be used
    with the 53 week year.

    If you need a pattern other than a 4-4-5 week pattern,
    then the day ranges must be adjusted to fit the other
    patterns of 4-5-4 or 5-4-4 weeks in an accounting
    calendar.  The YR445WK and YR455WK PROC FORMATs in the
    sample coding show a range of values for the number of
    days in a month (e.g., 1-28).  The label value in the
    PROC FORMATs show the month followed by the number of
    days from the beginning of the year (e.g., '01000').  The
    first line of the YR445WK PROC FORMAT sample is:

          1-28 = '01000'

    It shows that days 1-28 are in month 01 and there are 000
    days from the start of the year to the first day of month
    01.  Both the YR445WK and YR455WK PROC FORMATs must be
    adjusted if you are going to use a 4-5-4 or 5-4-4
    accounting calendar.  The YR455WK PROC FORMAT must be
    adjusted if the 11th month is not used for the extra week
    in the 53 week year.  The formats can be built with a SAS
    batch job.  To build the format in batch:

    //... JOB .......
    /*PROCLIB DSN=sharedprefix.MICS.PROCLIB
    //    EXEC MICSNDBx   /* Where x is the db identifier */
    //SYSIN DD *
      PROC FORMAT PRINT DDNAME=MCOLIB.USERFMT1;
       VALUE YR445WK
       1-28    = '01000'
       29-56   = '02028'
       57-91   = '03056'
       92-119  = '04091'
       120-147 = '05119'
       148-182 = '06147'
       183-210 = '07182'
       211-238 = '08210'
       239-273 = '09238'
       274-301 = '10273'
       302-329 = '11301'
       330-364 = '12329'
       OTHER   = 'UNKWN';
      PROC FORMAT PRINT DDNAME=MCOLIB.USERFMT1;
       VALUE YR455WK
       1-28    = '01000'
       29-56   = '02028'
       57-91   = '03056'
       92-119  = '04091'
       120-147 = '05119'
       148-182 = '06147'
       183-210 = '07182'
       211-238 = '08210'
       239-273 = '09238'
       274-301 = '10273'
       302-336 = '11301'
       337-371 = '12336'
       OTHER   = 'UNKWN';
     RUN;
D.  IMPLEMENTING THE CHANGES

    There are two alternatives that can be used to make the
    exit coding available to the CA MICS daily processing.
    Choose one of the alternatives based on your requirements
    and situation.  In either case, add the indicated code
    with any revisions that are necessary to the
    sharedprefix.MICS.SOURCE library as a new member.  As the
    implementation date of the new date routines into an
    existing system has multiple considerations, please
    consult the CA MICS Product Support Group. Use either
    Alternative I or Alternative II to implement the DWMY445
    routines.
     ALTERNATIVE I:  TO ADD THE NEW DATE ROUTINE TO ONE UNIT
                    AT A TIME


    1.  After you have completed parts A - D above, add the
        following SAS statement before the MACRO _WKSTART
        statement in #DWMY445 and just before the %MACRO
        WKSTART statement in $DWMY445:

          %INCLUDE SOURCE(#DWMY12);  in the #DWMY445 member
          %INCLUDE SOURCE($DWMY12);  in the $DWMY445 member

    2.  The #DWMY445 and $DWMY445 members must be added to
        the sharedprefix.MICS.SOURCE library with the
        modifications that you made.

    3.  Run BASPGEN from the prefix.MICS.CNTL library.
        Ensure that there are no errors in MICSLOG and that
        the job completes with a condition code of zero.

        Run BASPGEN for every database unit.

    After you have added the DWMY445 modules to the source
    library and run a BASPGEN, you can run a CA MICS DAILY.
    The YEAR, MONTH, WEEK, and DAY fields should be reviewed
    for validity after the Daily processing.
    ALTERNATIVE II:  ADD TO ALL UNITS SIMULTANEOUSLY

    This implementation adds the new date routine to all the
    units at the same time, and is usually used by sites that
    have previously used the #DWMY12 member or taken the
    default sharedprefix.MICS.PARMS(CPLXDEF) member and the
    default prefix.MICS.PARMS(SITE) member.

    Add the DWMY445 members into sharedprefix.MICS.SOURCE
    with the modifications that you have made.

    1.  After you have completed parts B -  D above, add the
        following SAS statement to #DWMY12 and $DWMY12 in the
        sharedprefix.MICS.SOURCE library:

         %INCLUDE SOURCE(#DWMY445); for the #DWMY12 member
         %INCLUDE SOURCE($DWMY445); for the $DWMY12 member

    2.  The #DWMY445 and $DWMY445 members must be added to
        the sharedprefix.MICS.SOURCE library with the
        modifications that you made.

    3.  Run BASPGEN from the prefix.MICS.CNTL library.
        Ensure that there are no errors in MICSLOG and that
        the job completes with a condition code of zero.

        Run BASPGEN for every database unit.

     Your next Daily will reflect the new date routines and
     the YEAR, MONTH, WEEK, and DAY fields should be reviewed
     for validity.