Previous Topic: 4.7.2.1 Twelve Month Calendar Modifications

Next Topic: 4.7.2.3 Calendar Modifications for 445/454/544 Calendars

4.7.2.2 Thirteen Month Calendar Modifications


If your organization needs to operate CA MICS on a 13-month
year, consider the following in addition to the information
provided for Gregorian-based calendar installations.

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.

For CA MICS to summarize and store data in a manner
consistent with your 13-month year, you must provide CA MICS
with information about your fiscal calendar.  While you will
see later how to specify this information, in general you
must determine:

o When each fiscal year begins

o Whether the fiscal year is the same year as the
  Gregorian calendar year

o How many years of data you need to keep

o What you will call each of the 13 months, henceforth
  referred to as periods

CA MICS uses this information to arrive at proper
Gregorian-to-13-month date conversion routines that enable it
to summarize and store data consistent with your fiscal
calendar. It is your responsibility to ensure that your
13MONTHYEAR parameter statements and any related SAS code
are maintained correctly into the future.

To implement a 13-month fiscal calendar in CA MICS, you must
answer the following questions.
o  When does each fiscal year begin?

   Ask those in your organization who established or
   maintain the 13-month calendar your enterprise utilizes.
   The dates you specify to CA MICS will be the same dates
   that your Accounting or Financial departments use to
   describe the year.  This information will be used to code
   the complex-level shareprefix.MICS.PARMS(CPLXDEF) or
   unit-level prefix.MICS.PARMS(SITE) member, and also to
   generate a format used in CA MICS processing and by some
   management support applications like the CA MICS Capacity
   Planner and CA MICS Accounting and Chargeback.
o  Is the fiscal year the same as the Gregorian year?

   The answer to this question directly affects the kinds of
   modifications you will need to make in order to implement
   your calendar system in CA MICS.

   An example illustrates how you determine the answer to
   this question.  Suppose that your installation has a year
   that begins on January 1, 1996.  The question to ask is
   "Is the fiscal year 1996 or is it 1997?"
o  How many years of data need to be kept?

   Refer to Section 4.7.2 of this guide for a discussion of
   this topic.

o  What will each period (month) be called?

   CA MICS uses a SAS format, MNTHFMT, to provide the full
   name of a month from a number (see PIOM, Section
   2.3.2.4).  Many 13-month installations call their 13
   periods P01 through P13.  This strategy sufficiently
   differentiates among the periods and eliminates confusing
   13-month periods with Gregorian months.  Whatever
   strategy you adopt to call the periods, they should be
   unique in the first three characters of the name.

Once the determinations above have been made, you are ready
to make the necessary specifications and modifications to
CA MICS.  For implementing 13-month fiscal calendars in
CA MICS, the process is:
     1.  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 YES #DWMY=#memname ddmonyy ddmonyy...

         where #memname is your modified member that begins
         with #DWMY or $DWMY and ddmonyy is the start date
         for each of the 13-month years.  (See the PIOM,
         Sections 2.3.1.8 and 2.3.2.4).

         Do not code more than 8 years on this statement.
         Your #memname routine may handle more than 8 years,
         but since this parameter handles only 8, it must be
         updated in the future.

         BASPGEN is coded to include #DWMYxxx and $DWMYxxx
         from the #BASMSTR and $BASMSTR modules it generates,
         respectively.  If '#memname' does not begin with
         #DWMY, BASPGEN generates code to include #memname
         from the #BASMSTR and $BASMSTR modules.

         Proceed through the rest of this checklist and at
         Step 6, Generating and Loading the YRSTART Format,
         you will "Redefine" the years (i.e., create your own
         YRSTART format).
     2.  CODE THE CHANGES FOR #memname AND $memname

         a.  The modifications to the default member
            sharedprefix.MICS.SOURCE(#DWMY13) for #memname
            (which contains the date macros written with SAS
            MACRO statements) are shown below.

            The highlighted line of code in the YEAR macro is
            changed according to your site's fiscal year
            start date.  To decide what value to code, use
            the following technique:

            - If the fiscal year begins on January 1, 1996
              and your site calls this fiscal year 1997,
              subtract 1899 in the YEAR macro because the
              year of the start date (1996) minus 1899 yields
              97.
            - If the fiscal year begins on January 1, 1996
              and your site calls this fiscal year 1996,
              subtract 1900 because the start date year
              (1996) minus 1900 yields 96.

            To rewrite the YEAR macro, use one of the
            following techniques:

            - Code SELECT statements.  For example,

              MACRO _YEAR
                _SETYRST
                SELECT;
                  WHEN (YRSTART EQ '01JAN96'D) SUBYEAR=1899;
                  WHEN (YRSTART EQ '01JAN97'D) SUBYEAR=1899;
                  WHEN (YRSTART EQ '01JAN98'D) SUBYEAR=1899;
                  WHEN (YRSTART EQ '30DEC98'D) SUBYEAR=1898;
                  WHEN (YRSTART EQ '01JAN99'D) SUBYEAR=1898;
                  OTHERWISE DO;
                    FILE LOG;
                    PUT '>ERR> ' YRSTART DATE9.
                        ' NOT IN DEFINED in #DWMY13.';
                    ABORT ABEND 510;
                  END;
                END;
                YEAR=YEAR(YRSTART)-SUBYEAR;
              %

              Of course, you need to specify start dates for
              your fiscal years where the example above has
              coded the SAS DATE constants.

              SAS SELECT logic enables you to specify each of
              the years individually, providing a form of
              documentation that, as a System Administrator,
              you may find helpful.

            - Use "IF" or "IF-THEN-ELSE" logic.

              If, for instance, all the years that you
              defined have the same number subtracted from
              them in order to arrive at the fiscal year,
              then the only modification would be to the line
              containing 1900 as discussed above.

              If only one year required subtracting a
              different amount than all others, consider
              coding a statement that identifies that year
              and takes an action; it does something
              different for all other years.


          DEFAULT #DWMY13 MEMBER SHIPPED WITH CA MICS


Note:  Annotations to logic are shown by <== indicating the
       area for comment, and end in !! for separation.  These
       annotations are not SAS code.


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


   MACRO _MONTHDF 13%

   MACRO _DAY
     _SETYRST
     DAY=MOD(ENDDT-YRSTART+1,28);
     IF DAY=0 THEN DAY=28;
     IF ENDDT-YRSTART>363 THEN DAY=ENDDT-YRSTART-335;
   %

   MACRO _WEEK
     _SETYRST
     IF WEEKDAY(YRSTART)-_WKSTART >= 0 THEN
      WEEK=INT((ENDDT-YRSTART+WEEKDAY(YRSTART)
      -_WKSTART)/7+1);
     ELSE WEEK=INT((ENDDT-YRSTART+WEEKDAY(YRSTART)
      -_WKSTART+7)/7+1);
   %

   MACRO _MONTH
     _SETYRST
     MONTH=INT((ENDDT-YRSTART+1)/28);
     IF MOD((ENDDT-YRSTART+1),28) NE 0 THEN MONTH=MONTH+1;
     IF MONTH>13 THEN MONTH=13;
   %

   MACRO _YEAR
     _SETYRST
     YEAR=YEAR(YRSTART)-1900;             <== changes here!!
   %

   MACRO _SETYRST
     ENDDT=DATEPART(ENDTS);
     YRSTART=INPUT(PUT(ENDDT,YRSTART.),5.);

     IF YRSTART=. THEN DO;
       FILE LOG;
       PUT '>ERR> ' ENDDT DATE9. ' NOT IN DEFINED YEARS.'/
         '>>>>> START OF YEAR LIST MUST BE UPDATED IN '/
         'MICS.PARMS(SITE) PARAMETER "13MONTHYEAR" AND '/
         'BASPGEN JOB RUN.';
       ABORT ABEND 510;
     END;
   %


   MACRO _PREVWK
     /* SELECT ONLY DATA FROM THE PREVIOUS WEEK.       */
     /* CALCULATE PREVIOUS WEEK BY SUBTRACTING 1       */
     /* FROM THE WEEK VALUE OF TODAY.                  */
     /* (USING THE _WEEK MACRO). IF AFTER SUBTRACTION  */
     /* THE WEEK IS FOUND TO BE ZERO,                  */
     /* (THIS WILL HAPPEN THE FIRST WEEK OF THE YEAR), */
     /* THE WEEK OF                                    */
     /* THE LAST DAY OF THE PREVIOUS YEAR IS USED.     */

     RETAIN PREVWK; DROP PREVWK;
     IF PREVWK=. THEN DO;
     /* H_WEEK IS USED TO HOLD THE WEEK VALUE OF       */
     /* THE CURRENT OBSERVATION                        */
     /* WHILE THE PREVIOUS WEEK IS BEING CALCULATED    */
     H_TS=ENDTS;
     H_WEEK=WEEK;
     ENDTS=DHMS(TODAY(),0,0,0);
     _WEEK
     PREVWK=WEEK-1;
     IF PREVWK=0 THEN DO;
       ENDTS=DHMS(YRSTART-1,0,0,0);
       _WEEK;
       PREVWK=WEEK;
     END;
     ENDTS=H_TS;
     WEEK=H_WEEK;
     END;
     IF WEEK = PREVWK;
     %

         b. For $memname (which contains the date macros
            written in SAS Macro language), the code
            illustrated below illustrates the situation
            described above for the #memname case.

            %MACRO YEAR;
              %SETYRST;
              SELECT;
              WHEN (YRSTART EQ '01JAN96'D) SUBYEAR=1899;
              WHEN (YRSTART EQ '01JAN97'D) SUBYEAR=1899;
              WHEN (YRSTART EQ '01JAN98'D) SUBYEAR=1899;
              WHEN (YRSTART EQ '30DEC98'D) SUBYEAR=1898;
              WHEN (YRSTART EQ '01JAN99'D) SUBYEAR=1898;
              OTHERWISE DO;
                 FILE LOG;
                 PUT '>ERR> ' YRSTART  DATE9.
                     ' NOT IN DEFINED in $DWMY13.';
                 ABORT ABEND 510;
              END;
              END;
              YEAR=YEAR(YRSTART)-SUBYEAR;
            %MEND YEAR;

            Note:  The processes for arriving at the dates
            and values to be subtracted are the same as
            discussed in the previous section.

            You need to specify start dates for your fiscal
            years where the example above has coded the SAS
            DATE constants.

            You can determine the necessary dates and values
            by using "IF" or "IF-THEN-ELSE" logic.  If, for
            instance, all the years that you defined have the
            same number subtracted from them in order to
            arrive at the fiscal year, then the only
            modification would be to the line containing 1900
            as discussed in the #DWMY13 section.

            SAS SELECT logic enables you to specify each of
            the years individually, providing a form of
            documentation that, as System Administrator, you
            may find helpful.

            If only one year required subtracting a different
            amount than all others, you might find it simpler
            to code a statement that identifies that year and
            takes an action; it does something different for
            all other years.

          DEFAULT $DWMY13 MEMBER SHIPPED WITH CA MICS

   %LET MONTHDF=13;

   %MACRO DAY;
     %SETYRST;
     IF ENDDT-YRSTART GT 363 THEN DAY=ENDDT-YRSTART-335;
     ELSE DO;
       DAY=MOD(ENDDT-YRSTART+1,28);
       IF DAY EQ 0 THEN DAY=28;
     END;
   %MEND DAY;

   %MACRO WEEK;
     %SETYRST;
     IF WEEKDAY(YRSTART)-&WKSTART GE 0 THEN
      WEEK=INT((ENDDT-YRSTART+WEEKDAY(YRSTART)
           -&WKSTART)/7+1);
     ELSE WEEK=INT((ENDDT-YRSTART+WEEKDAY(YRSTART)
               -&WKSTART+7)/7+1);
   %MEND WEEK;
   %MACRO MONTH;
     %SETYRST;
     MONTH=INT((ENDDT-YRSTART+1)/28);
     IF MOD((ENDDT-YRSTART+1),28) NE 0 THEN MONTH=MONTH+1;
     IF MONTH GT 13 THEN MONTH=13;
   %MEND MONTH;

   %MACRO YEAR;
      %SETYRST;
      YEAR=YEAR(YRSTART)-1900;            <== changes here!!
   %MEND YEAR;

   %MACRO SETYRST;
    ENDDT=DATEPART(ENDTS);
    YRSTART=INPUT(PUT(ENDDT,YRSTART.),5.); <== 5. to Date7.!!
    IF YRSTART EQ . THEN DO;
      VARX=PUT(ENDDT,DATE9.);
      CALL MICSLOG('BAS00473');
      ABORT ABEND 510;
    END;
   %MEND SETYRST;
         3.  MODIFY THE MNTHFMT FORMAT

         The sharedprefix.MICS.SOURCE member MNTHFMT provides
         the full name for periods or months based on the
         period or month number.  Modify MNTHFMT to use the
         names you decided upon earlier in this section.  The
         MNTHFMT illustrated below shows periods P01 through
         P13.

                  PROC FORMAT LIBRARY=MCOLIB.USERFMT2;
                  VALUE MNTHFMT
                     1  = 'P01'
                     2  = 'P02'
                     3  = 'P03'
                     4  = 'P04'
                     5  = 'P05'
                     6  = 'P06'
                     7  = 'P07'
                     8  = 'P08'
                     9  = 'P09'
                     10 = 'P10'
                     11 = 'P11'
                     12 = 'P12'
                     13 = 'P13';


         Note:  These changes become effective when you run
                BASPGEN.
     4.  SAVE YOUR MODIFICATIONS

         Ensure that you have backed up your databases and
         libraries before saving both the #memname and
         $memname members and the MNTHFMT member in the
         sharedprefix.MICS.SOURCE library.
     5.  MAKE THESE CHANGES EFFECTIVE

         For each unit, submit the job in
         prefix.MICS.CNTL(BASPGEN).  Ensure that there are no
         error messages in MICSLOG and that the job completes
         with a condition code of zero.
     6.  (Conditional) GENERATE AND LOAD THE YRSTART FORMAT

         If your site needs more than 8 years of data, or
         your 'year start' value requires 2 dates that start
         in the same calendar year (i.e., 01JAN98 and
         28DEC98), you can code a PROC FORMAT table to
         associate the year start date with a date range.
         
         Modify the YRSTART macro to accept a DATE7. Code the
         format of the year start date for convenience
         in the format statements.

   %MACRO SETYRST;
    ENDDT=DATEPART(ENDTS);
    YRSTART=INPUT(PUT(ENDDT,YRSTART.),5.); <== 5. to Date7.!!
    IF YRSTART EQ .  THEN DO;
      VARX=PUT(ENDDT,DATE9.);
      CALL MICSLOG('BAS00473');
      ABORT ABEND 510;
    END;
   %MEND SETYRST;

         Finally, generate a YRSTART format to use in the
         CA MICS date processing routines that you have
         modified.  The format must take the following form:

          PROC FORMAT LIBRARY=MCOLIB.USERFMT1 PRINT;
            VALUE YRSTART
             OTHER='.'
             '01JAN96'D - '31DEC96'D = '01JAN96'

                  ...

             '01JAN98'D - '31DEC98'D = '01JAN98';

         For each year that you wish to specify to CA MICS,
         you must code a SAS statement like the one above,
         substituting your first and last dates where the
         date constants are in the example.  The form is:

          'first date'D - 'last date'D = 'year start date'

         Do NOT specify the Date (D) constant modifier for
         the year start date!

         Note:  The YRSTART format is recreated and written
         to the prefix.MICS.MUOLIB MICSFMTS format catalog
         every time BASPGEN is executed.  In order to use
         your calendar definitions, we recommend you write
         your YRSTART format to the MCOLIB.USERFMT1 library,
         as shown above.  This way, because of the catalog
         search order CA MICS specifies at initialization,
         your format will always be found first, and
         consequently, used.

         The YRSTART format must be a permanent SAS format.
         Section 4.5 of this guide provides instructions for
         creating permanent user-defined formats.

         Successfully generating and saving this format
         concludes the implementing process for 13-month
         calendars.