Resources

Getting Started and Details Examples (bom0)

/**************************************************************/
/*                                                            */
/*          S A S   S A M P L E   L I B R A R Y               */
/*                                                            */
/*    NAME: BOM0                                              */
/*   TITLE: Getting Started and Details Examples (bom0)       */
/* PRODUCT: OR                                                */
/*  SYSTEM: ALL                                               */
/*    KEYS: OR PPLOT                                          */
/*   PROCS: BOM, PRINT, NETDRAW, SQL                          */
/*    DATA:                                                   */
/*                                                            */
/* SUPPORT:                             UPDATE:               */
/*     REF:                                                   */
/*    MISC: Examples from the Getting Started and Details     */
/*          sections in the BOM Procedure chapter from the    */
/*          BOM book.                                         */
/*                                                            */
/**************************************************************/


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

 Getting Started

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

/* Part master records */

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


/* Product structure records  */

data ParComp0;
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
;


/* Display the part master file */

proc print data=PMaster0;
   title 'ABC Lamp Company';
   title3 'Part Master Data Set';
run;


/* Display the product structure file */

proc print data=ParComp0;
   title 'ABC Lamp Company';
   title3 'Product Structure Data Set';
run;

  /* Create the indented BOM and summarized parts list */
proc bom data=ParComp0 pmdata=PMaster0
         out=IndBOM0 summaryout=SumBOM0;
   structure / part=Part
               parent=Parent
               component=Component
               quantity=QtyPer
               id=(Desc Unit);
run;

  /* Display the indented BOM data */
proc print data=IndBOM0 noobs;
   var _Level_ _Parent_ _Part_ Desc QtyPer Qty_Prod
       Unit Paren_ID Part_ID _Prod_;
   title 'ABC Lamp Company';
   title3 'Indented Bill of Material, Part LA01';
run;


proc bom data=ParComp0 pmdata=PMaster0
         out=IndBOM0 summaryout=SumBOM0;
   structure / part=Part
               parent=Parent
               component=Component
               quantity=QtyPer
               id=(Desc Unit);
run;


data IndBOM0a(drop=Part_ID);
   set IndBOM0;
   Paren_ID=Part_ID;
run;

  /* Draw a tree diagram for illustating the product structure */
  /* Each record denotes a node in the tree */

data IndBOM0a(drop=Part_ID);
   set IndBOM0;
   Paren_ID=Part_ID;
run;


  /* Extract the Parent - Part information */

data IndBOM0b;
   set IndBOM0(keep=Paren_ID Part_ID);
run;


 /* Prepare the data set for running NETDRAW */

data TreBOM0;
   set IndBOM0a IndBOM0b;
run;


  /* Specify graphics options */

goptions hpos=80 vpos=32;
pattern1 v=e c=blue;
title h=2 j=c 'Bill of Material Tree Diagram';
title2;
footnote2;
footnote3 h=1 j=l
   'Node shows Sequence Number and Part Number';




  /* Invoke PROC NETDRAW to display BOM tree */

proc netdraw data=TreBOM0( where=(Paren_ID NE .) ) out=NetOUT;
   actnet / act=Paren_ID succ=Part_ID id=(Paren_ID _Part_)
            ctext=black htext=3 font=swiss carcs=black
            ybetween=3 xbetween=32 centerid
            tree pcompress rotatetext rotate
            arrowhead=0 rectilinear nodefid nolabel;
run;




/* Sort and display the summarized parts list */

proc sort data=SumBOM0;
by _Part_;
run;

proc print data=SumBOM0 noobs;
title 'ABC Lamp Company';
title3 'Summarized Parts List, Period 1';
run;


  /* Display the components that are directly used */
  /* in item LA01                                  */
proc print data=IndBOM0(where=(_Parent_='LA01')
                        rename=(_Part_=Component))
           noobs;
   var Component Desc QtyPer Unit;
   title 'ABC Lamp Company';
   title3 'Single-level Bill of Material Retrieval, Part LA01';
run;

  /* Create the where-used data set */
data Used0a(keep=_Parent_ Paren_ID QtyPer Unit);
   set IndBOM0(where=(_Part_='1400'));
run;

  /* Get the part description from the IndBOM0 data set */
proc sql;
   create table Used0b as
      select Used0a._Parent_, IndBOM0.Desc,
             Used0a.QtyPer, Used0a.Unit
         from Used0a left join IndBOM0
            on Used0a.Paren_ID=IndBOM0.Part_ID;
quit;

  /* Display the where-used data set */
proc print data=Used0b noobs;
   var _Parent_ Desc QtyPer Unit;
   title 'ABC Lamp Company';
   title3 'Single-level Where-used Report, Part 1400';
run;