Resources

Examples from the BOM Macros chapter (bommacro)

/**************************************************************/
/*          S A S   S A M P L E   L I B R A R Y               */
/*                                                            */
/*    NAME: BOMMACRO                                          */
/*   TITLE: Examples from the BOM Macros chapter (bommacro)   */
/* PRODUCT: OR                                                */
/*  SYSTEM: ALL                                               */
/*    KEYS: OR                                                */
/*   PROCS: BOM, PRINT                                        */
/*    DATA:                                                   */
/*                                                            */
/* SUPPORT:                             UPDATE:               */
/*     REF:                                                   */
/*    MISC:                                                   */
/*                                                            */
/**************************************************************/

      title 'Examples from BOM Postprocessing Macros chapter';

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

                        Input Data Sets

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


/* Part master records */

data PMaster;
 input Part      $8.
       Desc      $24.
       Unit      $8.
       LeadTime  8.0
       ;
datalines;
1100    Finished shaft          Each           2
1200    6-Diameter steel plate  Each           3
1300    Hub                     Each           2
1400    1/4-20 Screw            Each           1
1500    Steel holder            Each           2
1600    One-way socket          Each           2
1601    Three-way socket        Each           2
1700    Wiring assembly         Each           1
2100    3/8 Steel tubing        Inches         3
2200    16-Gauge lamp cord      Feet           2
2210    14-Gauge lamp cord      Feet           2
2300    Standard plug terminal  Each           1
A100    One-way socket assem.   Each           1
A101    Three-way socket assem. Each           1
B100    Base assembly           Each           1
LA01    Lamp LA                 Each           2
S100    Black shade             Each           2
;



/* Product structure records  */

data ParComp;
 format SDate EDate date9.;
 input Parent    $8.
       Component $8.
       QtyPer    4.0
       Fscrap    6.2
       LTOff     4.0
       SDate     date10.
       EDate     date10.
       ;
datalines;
LA01    A100       1   .     2         .         .
LA01    B100       1   .     .         .         .
LA01    S100       1   .     .         .         .
B100    1100       1   .     .         .         .
B100    1200       1   .     .         .         .
B100    1300       1   .     1         .         .
B100    1400       4   .     3         .         .
A100    1500       1   .     .         .         .
A100    1600       1   .     .         .         .
A100    1700       1   .     .         .         .
A101    1500       1   .     .         .         .
A101    1601       1   .     .         .         .
A101    1700       1   .     .         .         .
1100    2100      26  0.2    .         .         .
1500    1400       2   .     .         .         .
1700    2200      12  0.1    .         .  7APR2001
1700    2210      12  0.1    .  8APR2001         .
1700    2300       1   .     .         .         .
;



/* Create the Indented BOM data set */

proc bom data=ParComp pmdata=PMaster out=IndBOM;
 structure / part=Part
             leadtime=LeadTime
             parent=Parent
             component=Component
             quantity=QtyPer
             factor=Fscrap
             offset=LTOff
             id=(Desc Unit)
             rid=(SDate EDate);
run;


/* Display the Indented BOM data */

proc print data=IndBOM;
 var _Level_ _Parent_ Paren_ID _Part_ Part_ID Desc QtyPer
     Fscrap Qty_Prod Unit LeadTime Tot_Lead LTOff Tot_Off
     SDate EDate _Prod_;
 title 'ABC Lamp Company';
 title3 'Indented Bill of Material';
run;

   %bomrmlb(root='A100', in=IndBOM, quantity=QtyPer,
            factor=Fscrap, leadtime=LeadTime, offset=LTOff,
            out=BomOut1, drop=Paren_ID Part_ID _Prod_);


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

                        Report Macros

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


/* BOMRMLB: Indented Bill of Material */

proc print data=BomOut1 noobs;
 var _Level_ _Parent_ _Part_ Desc QtyPer Fscrap Qty_Prod
     Unit LeadTime Tot_Lead LTOff Tot_Off SDate EDate;
 title 'ABC Lamp Company';
 title2 '%BOMRMLB macro';
 title3 'Indented Bill of Material, Part A100';
run;

/* BOMRMLW: Indented Where-Used List */

%bomrmlw(root='1400', in=IndBOM, qtyused=QtyUsed,
out=BomOut2, drop=Paren_ID Part_ID Qty_Prod);


proc print data=BomOut2;
 var _Level_ _Parent_ _Part_ Desc QtyPer Fscrap QtyUsed Unit
     LeadTime Tot_Lead LTOff Tot_Off SDate EDate _Prod_;
 title 'ABC Lamp Company';
 title2 '%BOMRMLW macro';
 title3 'Indented Where-Used List, Part 1400';
run;

/* BOMRMLW: Indented Where-Used List */

%bomrslb(root='B100', in=IndBOM, out=BomOut3);


proc print data=BomOut3 noobs;
var _Parent_ _Part_ Desc QtyPer Fscrap Unit
  LeadTime LTOff SDate EDate;
title 'ABC Lamp Company';
title2 '%BOMRSLB macro';
title3 'Single-Level Bill of Material, Part B100';
run;

/* BOMRSLW: Single-Level Where-Used List */

%bomrslw(root='1400', in=IndBOM, quantity=QtyPer,
rid=SDate EDate, qtyused=QtyUsed, out=BomOut4);


proc print data=BomOut4 noobs;
var _Parent_ Desc QtyUsed Fscrap Unit LeadTime LTOff
  SDate EDate;
title 'ABC Lamp Company';
title2 '%BOMRSLW macro';
title3 'Single-Level Where-Used List, Part 1400';
run;

/* BOMRSUB: Summarized Bill of Material */

%bomrsub(root='LA01', in=IndBOM, quantity=QtyPer, qtyreq=QtyReq,
rid=SDate EDate LTOff Fscrap, req=50, out=BomOut5);



proc print data=BomOut5 noobs;
var _Part_ Desc Unit LeadTime QtyReq;
title 'ABC Lamp Company';
title2 '%BOMRSUB macro';
title3 'Summarized Bill of Material, Part LA01: Requirement=50';
run;


/* BOMRSUW: Summarized where-used list */

%bomrsuw(root='1400', in=IndBOM, quantity=QtyPer,
qtyused=QtyUsed, rid=SDate EDate LTOff Fscrap,
out=BomOut6);



proc print data=BomOut6 noobs;
var _Part_ Desc Unit LeadTime QtyUsed;
title 'ABC Lamp Company';
title2 '%BOMRSUW macro';
title3 'Summarized Where-Used List, Part 1400';
run;


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

 Transaction Macros

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

/* New product structure record  */

data ParComp1;
format SDate EDate date9.;
input _Parent_  $8.
    _Part_    $8.
    QtyPer    4.0
    Fscrap    6.2
    LTOff     4.0
    SDate     date10.
    EDate     date10.
    ;
datalines;
1700    1400       1   .     .         .         .
;


/* Display the new product structure record */


proc print data=ParComp1 noobs;
var _Parent_ _Part_ QtyPer Fscrap LTOff SDate EDate;
title 'ABC Lamp Company';
title3 'Product Structure Record; Parent 1700, Component 1400';
run;

/* BOMTCNP: Copy-and-Paste Transaction */

%bomtcnp(root='1400', attach='1700', in=IndBOM, psdata=ParComp1,
quantity=QtyPer, offset=LTOff, factor=Fscrap,
leadtime=LeadTime, id=Desc Unit, rid=SDate EDate,
out=BomOut7);


proc print data=BomOut7;
var _Level_ _Parent_ Paren_ID _Part_ Part_ID Desc QtyPer
  Fscrap Qty_Prod Unit LeadTime Tot_Lead LTOff Tot_Off
  SDate EDate _Prod_;
title 'ABC Lamp Company';
title2 '%BOMTCNP macro';
title3 'Indented Bill of Material';
run;

/* BOMTDEL: Multiple-Delete Transaction */

%bomtdel(root='2200', in=IndBOM, out=BomOut8);


proc print data=BomOut8;
var _Level_ _Parent_ Paren_ID _Part_ Part_ID Desc QtyPer
  Fscrap Qty_Prod Unit LeadTime Tot_Lead LTOff Tot_Off
  SDate EDate _Prod_;
title 'ABC Lamp Company';
title2 '%BOMTDEL macro';
title3 'Indented Bill of Material';
run;

/* BOMTREP: Multiple-Replace Transaction */

%bomtrep(root='A100', repby='A101', in=IndBOM, quantity=QtyPer,
offset=LTOff, factor=Fscrap, leadtime=LeadTime,
id=Desc Unit, rid=SDate EDate, del=1, out=BomOut9);


proc print data=BomOut9;
var _Level_ _Parent_ Paren_ID _Part_ Part_ID Desc QtyPer
Fscrap Qty_Prod Unit LeadTime Tot_Lead LTOff Tot_Off
SDate EDate _Prod_;
title 'ABC Lamp Company';
title2 '%BOMTREP macro';
title3 'Indented Bill of Material';
run;

/* BOMTSAE: Same-as-Except Transaction */

/* Part master records */

data PMaster1;
input Part      $8.
Desc      $24.
Unit      $8.
LeadTime  8.0
;
datalines;
LA03    Lamp LA w/ 3-way socket Each           2
;


/* Display the new product structure record */

proc print data=PMaster1 noobs;
title 'ABC Lamp Company';
title3 'Part Master Record; Part LA03';
run;

%bomtsae(root='LA03', sameas='LA01', except='A100', repby='A101',
in=IndBOM, pmdata=PMaster1, part=Part, quantity=QtyPer,
offset=LTOff, factor=Fscrap, leadtime=LeadTime,
id=Desc Unit, rid=SDate EDate, out=BomOut10);


proc print data=BomOut10;
var _Level_ _Parent_ Paren_ID _Part_ Part_ID Desc QtyPer
Fscrap Qty_Prod Unit LeadTime Tot_Lead LTOff Tot_Off
SDate EDate _Prod_;
title 'ABC Lamp Company';
title2 '%BOMTSAE macro';
title3 'Indented Bill of Material, Part LA03';
run;