Note: This SAS program is provided for illustration purposes only. To run the MRP Demo application, download the appropriate files from the Downloads page.
goptions ftext=swiss;
/****************************************************************/
/* Macro to Report Material Requirements */
/* Resulting from Master Production Schedule */
/****************************************************************/
%macro mat_use(a);
axis1 width=2 minor=none;
axis2 width=2 label=none minor=none;
symbol1 i=steplj v=none c=green w=1 l=1;
symbol2 i=steplj v=none c=cyan w=1 l=1;
symbol3 i=steplj v=none c=black w=3 l=1;
pattern1 c=cyan v=s;
pattern2 c=black v=empty;
proc gplot data=usage;
plot &a*_time_ / nolegend vzero vaxis=axis1
haxis=axis2 autovref lvref=33 areas=2;
run;
quit;
%mend;
/****************************************************************/
/* Macro to Report on Capacity Utilization */
/* Resulting from Master Production Schedule */
/****************************************************************/
%macro cap_use(location,stage);
axis1 width=2 minor=none;
axis2 width=2 label=none minor=none;
symbol1 i=steplj v=none c=green w=1 l=1;
symbol2 i=steplj v=none c=cyan w=1 l=1;
symbol3 i=steplj v=none c=black w=3 l=1;
pattern1 c=cyan v=s;
pattern2 c=black v=empty;
%if &stage=sew %then %do;
%let a = rsw_&location;
%let b = asw_&location;
%end;
%else %do;
%let a = rfn_&location;
%let b = afn_&location;
%end;
data temp;
keep capacity b _time_;
set usage;
capacity = &a; b = &b + &a;
run;
proc gplot data=temp;
plot (capacity b)*_time_ / overlay nolegend vzero vaxis=axis1
haxis=axis2 autovref lvref=33 areas=2;
run;
quit;
%mend;
/****************************************************************/
/* Macro to Report on Process Schedule */
/* Resulting from Master Production Schedule */
/****************************************************************/
%macro fac_sch(location,stage);
%if &stage=sew %then %do;
%let a = usw_&location;
pattern1 c=blue v=s;
%end;
%else %do;
%let a = ufn_&location;
pattern1 c=black v=l1;
%end;
data temp;
set schedule;
drop segmt_no;
if &a then output;
run;
proc gantt graphics data=temp;
id order product units;
chart / compress nojobnum nolegend cframe=ivory;
run;
%mend;
quit;
/****************************************************************/
/* Macro to Calculate Master Production Schedule */
/****************************************************************/
%macro cmps();
proc cpm data=problem resin=avail rout=usage out=schedule
interval=day;
id product order units segmt_no;
activity activity;
duration leadtime;
successor succ;
project project;
resource itl_010--pkg_440 line_7 woven f01 f02 f03 f06
sw_troy sw_gary sw_erie fn_troy fn_gary fn_erie
I4612 I4613 I4616 I4661 I42382
/ period=res_date obstype=type resid=res_name;
aligndate target;
aligntype targett;
run;
data schedule;
set schedule;
drop e_start e_finish l_start l_finish;
if units=. then delete;
run;
proc sort data=schedule;
by order s_start;
run;
%mend;
/****************************************************************/
/* Construct Activity Data Set */
/* from Input Data Sets on: */
/* Bills of Material */
/* Product Demand */
/* Manufacturing Parameters */
/* Resource Availability */
/****************************************************************/
%macro build();
/* extract resources from the mrp dataset */
proc sort data=mrp; by product; run;
proc transpose data=mrp out=resrce(drop=_name_);
by product;
id comp; idlabel desc;
var qty;
run;
/* construct a bom dataset for reporting */
proc transpose data=resrce out=bom;
run;
data bom;
keep label;
set bom;
label = _name_ || " " || _label_;
run;
/* add the Inventory Component as resource */
data resrce;
drop _name_;
set resrce;
sw_troy=.; sw_gary=.; sw_erie=.; fn_troy=.; fn_gary=.; fn_erie=.;
I4612 = .; I4613 = .; I4616 = .; I4661 = .; I42382 = .;
if product="43601020" then i4612=1;
else if product="43601030" then i4613=1;
else if product="43601060" then i4616=1;
else if product="43606010" then i4661=1;
else i42382=1;
run;
/* construct an inventory dataset for reporting */
data inventry;
format label $24.;
label = "43601020 " || " I4612"; output;
label = "43601030 " || " I4613"; output;
label = "43601060 " || " I4616"; output;
label = "43606010 " || " I4661"; output;
label = "892030802" || " I42382"; output;
run;
/* construct the activity dataset */
data activity;
format step $9. targett $3. project $12.;
set demand;
project="d"||left(trim(target));
targett = "mf";
succ=" "; leadtime=1; segmt_no=4;
activity=order || "_r"; step="release";
output;
targett="fle"; segmt_no=3;
succ=activity; leadtime=1;
activity=order || "_i"; step="inventory";
output;
targett="fle";
succ=activity; leadtime=2; /* simplifying assumption */
activity=order || "_f"; step="finish"; segmt_no=2;
output;
targett="fle";
succ=activity; leadtime=4; /* simplifying assumption */
activity=order || "_s"; step="sew"; segmt_no=1;
output;
run;
proc sort data=activity;
by target;
run;
data activit2;
set activity; by target;
if first.target;
product=.;
project=.;
order=.;
units=.;
step=.;
segmt_no=.;
activity="d"||left(trim(target));
succ=.;
targett="sge";
target=target-25;
run;
data activit3;
set activity activit2;
run;
/* extract manufacturing alternatives */
data manalt;
set manuf;
keep product line_7 woven f0: ;
if construc="Line 7" then line_7=1;
else if construc="Woven" then woven=1;
if finish=1 then f01=1;
else if finish=2 then f02=1;
else if finish=3 then f03=1;
else if finish=6 then f06=1;
output;
run;
/* put it all together */
proc sort data=activit3;
by product;
run;
proc sort data=resrce;
by product;
run;
proc sort data=manalt;
by product;
run;
data problem;
merge activit3 resrce manalt;
by product;
run;
data problem;
set problem;
array comp ITL_010--PKG_440;
array facl line_7 woven;
array fin f0:;
array inv I4612 I4613 I4616 I4661 I42382;
if step="sew" then do;
do over comp; comp=comp*units/leadtime; end;
do over facl; facl=facl*units; end;
do over inv; inv=.; end;
do over fin; fin=.; end;
end;
else if step="finish" then do;
do over comp; comp=.; end;
do over inv; inv=.; end;
do over facl; facl=.; end;
do over fin; fin=fin*units; end;
end;
else if step="inventory" then do;
do over comp; comp=.; end;
do over inv; inv=inv * (-units); end;
do over facl; facl=.; end;
do over fin; fin=.; end;
end;
else if step="release" then do;
do over comp; comp=.; end;
do over inv; inv=inv * units; end;
do over facl; facl=.; end;
do over fin; fin=.; end;
end;
run;
%mend;
/****************************************************************/
/* Macro to Report Master Production Schedule */
/* (Drives All Reports on Material Requirements, */
/* Facility Usage, Facility Production Schedules) */
/****************************************************************/
%macro mps();
pattern1 c=blue v=s;
pattern2 c=black v=l1;
pattern3 c=black v=e;
pattern4 c=black v=s;
title "Master Production Schedule";
proc gantt graphics data=schedule;
id order product units;
chart / compress nojobnum nolegend ss=s_start sf=s_finish
pattern=segmt_no cframe=yellow;
run;
quit;
%mend;
/*======================data & construction=====================*/
/****************************************************************/
/* Bill of Material Data */
/****************************************************************/
data mrp;
format product $12.;
input product $10. comp $10. desc $40. qty unit $ supply $;
if product=" " then product = l; l = product; retain l; drop l;
cards;
892030802004-1INDIGOFB KAI-5082-1W 1.6 mt no
120-X2773 Thread 0.0754 cn yes
PLB-1240 SN-Paper label Tops Woven label (small) 1 pc No
PKG-113B SN-Packaging Tops Polysheet 1 pc yes
PKG-113C SN-Packaging Tops Back Collar 1 st yes
PKG-440 Packaging 1 pc yes
CTN-L7 SN Packaging Corrugated Carton 0.05 st yes
43601020 ITL-010 SN-Interlining 0.75 mt No
BTN-306B SN-Button 436 Wband 1 pc No
BTN-319B SN-Button 436 Fly 4 pc No
BTN-302AF SN-Button (Fastener) 5 pc No
BTN-101C SN-Button (Burr) 6 pc No
BTN-101RA SN-Button (Rivet) 6 pc No
STK-217 SN-Barcode Bottoms 1 pc No
PCL-060 SN-Care label 1 pc No
STK-401 SN Leather Patch 436 & RT 1 pc No
OS-81 SN Packaging Carton Tag 0.05 pc No
01-1INDIGOFB XXXH Indigo 61 in. 1.4 mt No
96-5 SN-Pocketing 0.25 mt No
120-X2944 Thread/Red Orange-5000 mts 0.001 cn No
50-X2944 Thread/Red Orange-5000 mts 0.0032 cn No
75-X2944 Thread/Red Orange-5000 mts 0.0025 cn No
50-INDIGO Thread 0.001 cn No
75-INDIGO Thread 0.0011 cn No
25-NAT Thread 0.002 cn No
50-UNBLD Thread/Unbleached-5000mts 0.0013 cn No
75-UNBLD Thread/Unbleached-5000mts 0.0281 cn No
08-INDIGO Thread 0.0003 cn No
PKG-439 Packaging Plastic Sheet 4x4 1 pc No
PLB-B437N SN-Plb-437N Paper label 436 1 pc No
PLB-J438 SN-Plb J438/436 Guarantee Card 1 pc No
CTN-L7 SN Packaging Corrugated Ctn 0.05 st No
43601030 ITL-010 SN-Interlining 0.75 mt No
BTN-306B SN-Button 436 Wband 1 pc No
BTN-319B SN-Button 436 Fly 4 pc No
BTN-302AF SN-Button (Fastener) 5 pc No
BTN-101C SN-Button (Burr) 6 pc No
BTN-101RA SN-Button (Rivet) 6 pc No
STK-217 SN-Barcode Bottoms 1 pc No
PCL-060 SN-Care label 1 pc No
STK-401 SN Leather Patch 436 & RT 1 pc No
OS-81 SN Packaging Carton Tag 0.05 pc No
01-1INDIGOFB XXXH Indigo 61 in. 1.4 mt No
96-5 SN-Pocketing 0.25 mt No
120-X2944 Thread/Red Orange-5000 mts 0.001 cn No
50-X2944 Thread/Red Orange-5000 mts 0.0032 cn No
75-X2944 Thread/Red Orange-5000 mts 0.0025 cn No
50-INDIGO Thread 0.001 cn No
75-INDIGO Thread 0.0011 cn No
25-NAT Thread 0.002 cn No
50-UNBLD Thread/Unbleached-5000mts 0.0013 cn No
75-UNBLD Thread/Unbleached-5000mts 0.0281 cn No
08-INDIGO Thread 0.0003 cn No
PKG-439 Packaging Plastic Sheet 4x4 1 pc No
PLB-B437N SN-Plb-437N Paper label 436 1 pc No
PLB-J438 SN-Plb J438/436 Guarantee Card 1 pc No
CTN-L7 SN Packaging Corrugated Ctn 0.05 st No
43601060 ITL-010 SN-Interlining 0.75 mt No
BTN-306B SN-Button 436 Wband 1 pc No
BTN-319B SN-Button 436 Fly 4 pc No
BTN-302AF SN-Button (Fastener) 5 pc No
BTN-101C SN-Button (Burr) 6 pc No
BTN-101RA SN-Button (Rivet) 6 pc No
STK-217 SN-Barcode Bottoms 1 pc No
PCL-060 SN-Care label 1 pc No
STK-401 SN Leather Patch 436 & RT 1 pc No
OS-81 SN Packaging Carton Tag 0.05 pc No
01-1INDIGOFB XXXH Indigo 61 in. 1.4 mt No
96-5 SN-Pocketing 0.25 mt No
120-X2944 Thread/Red Orange-5000 mts 0.001 cn No
50-X2944 Thread/Red Orange-5000 mts 0.0032 cn No
75-X2944 Thread/Red Orange-5000 mts 0.0025 cn No
50-INDIGO Thread 0.001 cn No
75-INDIGO Thread 0.0011 cn No
25-NAT Thread 0.002 cn No
50-UNBLD Thread/Unbleached-5000mts 0.0013 cn No
75-UNBLD Thread/Unbleached-5000mts 0.0281 cn No
08-INDIGO Thread 0.0003 cn No
PKG-439 Packaging Plastic Sheet 4x4 1 pc No
PLB-B437N SN-Plb-437N Paper label 436 1 pc No
PLB-J438 SN-Plb J438/436 Guarantee Card 1 pc No
CTN-L7 SN Packaging Corrugated Ctn 0.05 st No
43606010 ITL-010 SN-Interlining 0.75 mt No
BTN-306B SN-Button 436 Wband 1 pc No
BTN-319B SN-Button 436 Fly 4 pc No
BTN-302AF SN-Button (Fastener) 5 pc No
BTN-101C SN-Button (Burr) 6 pc No
BTN-101RA SN-Button (Rivet) 6 pc No
STK-217 SN-Barcode Bottoms 1 pc No
PCL-060 SN-Care label 1 pc No
STK-401 SN Leather Patch 436 & RT 1 pc No
OS-81 SN Packaging Carton Tag 0.05 pc No
06-1INDIGOFB XXXH Indigo 61 in. 1.4 mt No
96-5 SN-Pocketing 0.25 mt No
120-X2944 Thread/Red Orange-5000 mts 0.001 cn No
50-X2944 Thread/Red Orange-5000 mts 0.0032 cn No
75-X2944 Thread/Red Orange-5000 mts 0.0025 cn No
50-INDIGO Thread 0.001 cn No
75-INDIGO Thread 0.0011 cn No
25-NAT Thread 0.002 cn No
50-UNBLD Thread/Unbleached-5000mts 0.0013 cn No
75-UNBLD Thread/Unbleached-5000mts 0.0281 cn No
08-INDIGO Thread 0.0003 cn No
PKG-439 Packaging Plastic Sheet 4x4 1 pc No
PLB-B437N SN-Plb-437N Paper label 436 1 pc No
PLB-J438 SN-Plb J438/436 Guarantee Card 1 pc No
CTN-L7 SN Packaging Corrugated Ctn 0.05 st No
;
/****************************************************************/
/* Demand Data from Forecasts */
/****************************************************************/
data demand;
informat target date7.;
format target date7. product $12.;
input order $8. product $10. units target date8.;
cards;
A0001 43601020 1000 1sep95
A0002 43601030 5000 1sep95
A0003 43601060 5000 1oct95
A0005 43606010 5000 1oct95
A0007 8920308020 5000 1nov95
b0001 43601020 1000 1nov95
b0002 43601030 5000 1nov95
b0003 43601060 5000 1nov95
b0005 43606010 5000 1nov95
b0007 8920308020 5000 1nov95
c0001 43601020 1000 1nov95
c0002 43601030 5000 1nov95
c0003 43601060 5000 1nov95
c0005 43606010 5000 1nov95
c0007 8920308020 5000 1nov95
d0001 43601020 1000 1nov95
d0002 43601030 5000 1nov95
d0003 43601060 5000 1nov95
d0005 43606010 5000 1nov95
d0007 8920308020 5000 1nov95
;
/****************************************************************/
/* Manufacturing Data */
/****************************************************************/
data manuf;
format product $12.;
input group $18. product $10. Construc $9. Fabric finish cost leadtime;
cards;
Jeanswear FivePckt 43601020 Line 7 01 02 12.25 14
Jeanswear FivePckt 43601030 Line 7 01 03 12.45 5
Jeanswear FivePckt 43601060 Line 7 01 06 12.00 14
Jeanswear FivePckt 43606010 Line 7 06 01 13.00 14
Jeanswear WovenTop8920308020 Woven 08 02 7.59 5
;
data capuse;
input location $ stage $ capacity;
process = trim(location) || "," || stage;
cards;
troy sew 10000
gary sew 1750
erie sew 8000
troy finish 7500
gary finish 2500
erie finish 8000
;
/****************************************************************/
/* Resource Availability Data */
/****************************************************************/
data avail;
informat res_date date7.;
format res_date date7.;
input type $8. res_name $8. res_date date8.
sw_troy sw_gary sw_erie fn_troy fn_gary fn_erie
line_7 woven f01 f02 f03 f06
I4612 I4613 I4616 I4661 I42382;
cards;
restype . . 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2
reslevel . 1aug95 10000 1750 8000 7500 2500 8000 0 0 0 0 0 0 0 0 0 0 0
reslevel . 1sep95 7000 1750 000 8500 1500 9000 0 0 0 0 0 0 0 0 0 0 0
reslevel . 1oct95 10000 1750 8000 7500 2500 8000 0 0 0 0 0 0 0 0 0 0 0
reslevel . 1nov95 19000 1750 8000 7500 2500 8000 0 0 0 0 0 0 0 0 0 0 0
altprty line_7 . 1 1 . . . . . . . . . . . . . . .
altprty woven . . . 1 . . . . . . . . . . . . . .
altprty f01 . . . . 1 1 1 . . . . . . . . . . .
altprty f02 . . . . 1 1 1 . . . . . . . . . . .
altprty f03 . . . . 1 1 1 . . . . . . . . . . .
altprty f06 . . . . 1 1 1 . . . . . . . . . . .
;
%build; /* build model */
%cmps; /* schedule model */
libname demo "<pathname of sasuser dir. containing mrp files>";
dm 'af c=demo.mrp.main.frame; pgm; icon;';