Resources

Roll-Up Cost in Indented Bill of Material (bome08)

/**************************************************************/
/*                                                            */
/*             S A S   S A M P L E   L I B R A R Y            */
/*                                                            */
/*    NAME: BOME08                                            */
/*   TITLE: Roll-Up Cost in Indented Bill of Material (bome08)*/
/* PRODUCT: OR                                                */
/*  SYSTEM: ALL                                               */
/*    KEYS: OR                                                */
/*   PROCS: BOM, PRINT, SORT                                  */
/*    DATA:                                                   */
/*                                                            */
/* SUPPORT:                             UPDATE:               */
/*     REF:                                                   */
/*    MISC: Example 8 from the BOM Procedure chapter of the   */
/*          BOM book.                                         */
/*                                                            */
/**************************************************************/


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

                     Use ParComp0 from BOMG01

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

/* Product structure records from BOMG01 */

data ParComp0;
format Parent Component $8.;
input Parent    $8.
      Component $8.
      QtyPer    4.0
      ;
datalines;
LA01    B100       1
LA01    S100       1
LA01    A100       1
B100    1100       1
B100    1200       1
B100    1300       1
B100    1400       4
A100    1500       1
A100    1600       1
A100    1700       1
1100    2100      26
1500    1400       2
1700    2200      12
1700    2300       1
;

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

                          Begin example

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

      /* Part master records */
   data PMaster8;
      format Part $8. Desc $24. Unit $8. Cost 8.2 ;
      input Part $ Desc & Unit $ Cost;
      datalines;
   1100    Finished shaft          Each         .
   1200    6-Diameter steel plate  Each        9.25
   1300    Hub                     Each        5.00
   1400    1/4-20 Screw            Each        0.20
   1500    Steel holder            Each         .
   1600    One-way socket          Each        3.50
   1700    Wiring assembly         Each         .
   2100    3/8 Steel tubing        Inches      0.05
   2200    16-Gauge lamp cord      Feet        0.35
   2300    Standard plug terminal  Each        0.50
   A100    Socket assembly         Each         .
   B100    Base assembly           Each         .
   LA01    Lamp LA                 Each         .
   S100    Black shade             Each        4.10
   ;

  /* Create the indented BOM */
proc bom pmdata=PMaster8 data=ParComp0 out=IndBOM8;
   structure / part=Part
               parent=Parent
               component=Component
               quantity=QtyPer
               id=(Desc Unit Cost);
run;

  /* Sort the indented BOM in reverse order */
proc sort data=IndBOM8(drop=_Prod_ Paren_ID);
   by descending Part_ID;
run;

  /* Roll up material cost */
data IndBOM8a;
   set IndBOM8;
   array costs[4] cost1 cost2 cost3 cost4;
   retain cost1 cost2 cost3 cost4 0;
   drop cost1 cost2 cost3 cost4;

   /* Determine the cost for the current item */
   if Cost=. then Cost=0;
   Cost = Cost + costs[_Level_+1];

   /* Roll up cost to the upper-level item */
   if _Level_ > 0 then
      costs[_Level_]=costs[_Level_]+(QtyPer*Cost);

   /* Reset roll up cost for the current level */
   costs[_Level_+1]=0;

   output;
run;

  /* Sort the indented BOM back to the original order */
proc sort data=IndBOM8a;
   by Part_ID;
run;

/* Display the indented BOM data */

proc print data=IndBOM8a noobs;
var _Level_ _Parent_ _Part_ Desc QtyPer Qty_Prod
    Unit Cost;
title 'ABC Lamp Company';
title3 'Indented Bill of Material, Part LA01';
run;