Category: Chapter 4 – Programs

Program 4.1


/****************************************************************************
* This program is taken from the following book. If using please cite it as:                            *
* Emrouznejad, A. and W. Ho (2012). Applied Operations Research with SAS, *
* CRC Press: Taylor Francis Ltd, ISBN: 9781439841303.*
* For details please visit: http://www.sas-or.com.                          *
****************************************************************************/


* A SAS procedure for project network of type Activity-On-Node;
%let _title=’Example 4.1. A project network: Activity-On-Node Format : Critical Path Analysis’;
%let dcpm=’c:/sasor/Data4_1.txt’;
%let _activity=task;
%let _duration=days;
option nodate;

* The data handling macro;
%macro data;
* Import text tab delimited data file to SAS data file;
proc import
datafile=&dcpm
out=dcpm
dbms=tab
replace;
getnames=yes;
run;

%mend data;
* The model building macro;
%macro model;
proc cpm
out=cpmout1;
activity &_activity;
duration &_duration;
successor succ1 succ2 succ3;
run;

%put &_ORCPM_;
%mend model;

%macro report;
data cpmout (where=(T_float=0));
set cpmout1;
run;

title &_title;
proc print
data =cpmout1 ;
run;

title &_title;
proc print
data =cpmout ;
sum &_duration;
run;
%mend report;

* Invoke PROC CPM to schedule the project specifying
* the ACTIVITY, DURATION and SUCCESSOR variables;
%macro orcpm;
%data;
%model;
%report;
%mend orcpm;

%orcpm;


/****************************************************************************
******************************END of the program*****************************
****************************************************************************/

Permanent link to this article: http://sas-or.com/book/program-4-1

Program 4.2

/***********************************************************************************
* This program is taken from the following book. If using please cite it as:           *
* Emrouznejad, A. and W. Ho (2012). Applied Operations Research with SAS, *
* CRC Press: Taylor Francis Ltd, ISBN: 9781439841303.                                               *
* For details please visit: http://www.sas-or.com.                                                                *
************************************************************************************/

* A SAS procedure for Activity-on-Node representation of the project with uncertainty ;
option nodate;
%let _title=’Example 4.2. A project network: Activity-On-Node Format: employs three probabilistic time estimates for each activity’;
%let _data=’c:/sasor/Data4_2.txt’;
%let _activity=task;
%let _duration=days;

* The data handling macro;
%macro data;
* Import text tab delimited data file to SAS data file;
proc import
datafile=&_data
out=dpert
dbms=tab
replace;
getnames=yes;
run;

data dpert;
set dpert;
days=(Opti+4*most+pessi)/6;
variance=((Opti-pessi)/6)**2;
run;
%mend data;

* The model building macro;
%macro model;
proc cpm
out=pertout;
activity &_activity;
duration &_duration;
successor succ1 succ2 succ3;
run;
%put &_ORCPM_;
%mend model;

* The report writing macro;
%macro report;

data pertout1 ;
merge dpert pertout;
by task;
run;

data pertout2 (where=(T_float=0));
merge dpert pertout;
by task;
run;

title &_title;
proc print
data =pertout1 ;
run;

proc print
data =pertout2 ;
sum T_float;
sum days;
sum variance;
run;
%mend report;

%macro orpert;
%data;
%model;
%report;
%mend orpert;

%orpert;


/****************************************************************************
******************************END of the program*****************************
****************************************************************************/

Permanent link to this article: http://sas-or.com/book/program-4-2

Exercise 4.1

/***********************************************************************************
* This program is taken from the following book. If using please cite it as:           *
* Emrouznejad, A. and W. Ho (2012). Applied Operations Research with SAS, *
* CRC Press: Taylor Francis Ltd, ISBN: 9781439841303.                                               *
* For details please visit: http://www.sas-or.com.                                                                *
************************************************************************************/

* A SAS procedure for project network of type Activity-On-Node: solution to exercise 4.1.;
%let _title=’A project network: Activity-On-Node Format: Critical Path ,Analysis, solution to exercise 4.1.’;
%let dcpm=’c:/sasor/Data4_1_exercise.txt’;
%let _activity=task;
%let _duration=days;
option nodate;

* The data handling macro;
%macro data;
* Import text tab delimited data file to SAS data file;
proc import
datafile=&dcpm
out=dcpm
dbms=tab
replace;
getnames=yes;
run;
%mend data;

* The model building macro;
%macro model;
proc cpm
out=cpmout1;
activity &_activity;
duration &_duration;
successor succ1 succ2 succ3;
run;
%put &_ORCPM_;
%mend model;
%macro report;
data cpmout (where=(T_float=0));
set cpmout1;
run;

title &_title;
proc print
data =cpmout1 ;
run;

title &_title;
proc print
data =cpmout ;
sum &_duration;
run;
%mend report;

* Invoke PROC CPM to schedule the project specifying
* the ACTIVITY, DURATION and SUCCESSOR variables;
%macro orcpm;
%data;
%model;
%report;
%mend orcpm;

%orcpm;


/****************************************************************************
******************************END of the program*****************************
****************************************************************************/

Permanent link to this article: http://sas-or.com/book/exercise-4-1

Exercise 4.2

/***********************************************************************************
* This program is taken from the following book. If using please cite it as:           *
* Emrouznejad, A. and W. Ho (2012). Applied Operations Research with SAS, *
* CRC Press: Taylor Francis Ltd, ISBN: 9781439841303.                                               *
* For details please visit: http://www.sas-or.com.                                                                *
************************************************************************************/


* A SAS procedure for project network of type Activity-On-Node: solution to exercise 3.8.;
%let _title=’A project network: Activity-On-Node Format: solution to exercise 4.2.’;
option nodate;
%let _data=’c:/sasor/Data4_2_exercise.txt’;
%let _activity=task;
%let _duration=days;

* The data handling macro;
%macro data;
* Import text tab delimited data file to SAS data file;
proc import
datafile=&_data
out=dpert
dbms=tab
replace;
getnames=yes;
run;

data dpert;
set dpert;
days=(Opti+4*most+pessi)/6;
variance=((Opti-pessi)/6)**2;
run;
%mend data;

* The model building macro;
%macro model;
proc cpm
out=pertout;
activity &_activity;
duration &_duration;
successor succ1 succ2 succ3;
run;
%put &_ORCPM_;
%mend model;

* The report writing macro;
%macro report;

data pertout1 ;
merge dpert pertout;
by task;
run;

data pertout2 (where=(T_float=0));
merge dpert pertout;
by task;
run;

title &_title;
proc print
data =pertout1 ;
run;

proc print
data =pertout2 ;
sum T_float;
sum days;
sum variance;
run;
%mend report;

%macro orpert;
%data;
%model;
%report;
%mend orpert;

%orpert;


/****************************************************************************
******************************END of the program*****************************
****************************************************************************/

Permanent link to this article: http://sas-or.com/book/exercise-4-2