Exercise 9.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.                                                                *
************************************************************************************/

* Using PROC OPTMODEL for Efficiency Measurement with Data Envelopment Analysis (DEA): solution to exercise 9.2;
option nodate ;
%let _title=’Efficiency Measurement Using Data Envelopment Analysis (DEA): solution to exercise 9.2′;
%let _InData=’C:\sasor\Data9_2_In_exercise.txt’;
%let _OutData=’C:\sasor\Data9_2_Out_exercise.txt’;
%let _nInput=3;
%let _nOutput=2;
%let _nUnits=20;
%let _Orienta=’OUTPUT’; *alternative option is ‘OUTPUT’ for output orientation;
%let _outdea1=EffOutOri;
%let _outdea2=EffInOri;

/*NOTE to Convexity constraints in both models for VRS;*/

* The data handling macro;
%macro data;
* Import text tab delimited input variables to SAS data file;
proc import
datafile=&_InData
out=data17_input
dbms=tab
replace;
getnames=yes;
run;
* Import text tab delimited output variables to SAS data file;
proc import
datafile=&_OutData
out=data17_output
dbms=tab
replace;
getnames=yes;
run;
%mend data;

* A DEA macro for CRS output orientation;
%macro model_outOri (j0);
* Starting OPTMODEL Procedure;
proc optmodel;
* Define sets;
set INPUTS=1..&_nInput;
set OUTPUTS=1..&_nOutput;
set UNITS=1..&_nUnits;

* Define variables;
var L{UNITS} >=0;
var Sin{INPUTS} >=0 ;
var Sout{OUTPUTS} >=0 ;
var h;

* Define parameters;
number Xin{UNITS, INPUTS};
number Yout{UNITS,OUTPUTS};
string DMUS{UNITS};
number eff;
string DMUj0;

* Load unit names;
read data data17_input
into [_N_]
DMUS[_N_]=col(‘dmu’);

* Load matrix of input variables;
read data data17_input
into [_N_]
{i in INPUTS} <Xin[_N_,i]=col(‘input’||i)>;

* Load matrix of output variables;
read data data17_output
into [_N_]
{r in OUTPUTS} <Yout[_N_,r]=col(‘output’||r)>;

* Define objective function ;
max obj = h;

* Define constrains;
con InpCon_outOri{i in INPUTS}:
sum{j in UNITS} L[j]*Xin[j,i] + Sin[i]=Xin[&j0,i];

con OutCon_outOri{r in OUTPUTS}:
sum{j in UNITS} L[j]*Yout[j,r] – Sout[r]=h*Yout[&j0,r];

* Define convexity constraints for VRS models;
/* con Convexity: sum{j in UNITS} L[j]=1; */

* Solve the model;
solve ;

* Save the efficiency scores in a SAS dataset;
eff=1/h.sol;
DMUj0=DMUS[&j0];
create data solj0 from DMUj0 eff;

*End of PROC OPTMODE;
quit;
%mend model_outOri;

* A DEA macro for CRS input orientation;
%macro model_inOri (j0);


* Starting OPTMODEL Procedure;
proc optmodel;
* Define sets;
set INPUTS=1..&_nInput;
set OUTPUTS=1..&_nOutput;
set UNITS=1..&_nUnits;

* Define variables;
var L{UNITS} >=0;
var Sin{INPUTS} >=0 ;
var Sout{OUTPUTS} >=0 ;
var h;

* Define parameters;
number Xin{UNITS, INPUTS};
number Yout{UNITS,OUTPUTS};
string DMUS{UNITS};
number eff;
string DMUj0;

* Load unit names;
read data data17_input
into [_N_]
DMUS[_N_]=col(‘dmu’);

* Load matrix of input variables;
read data data17_input
into [_N_]
{i in INPUTS} <Xin[_N_,i]=col(‘input’||i)>;

* Load matrix of output variables;
read data data17_output
into [_N_]
{r in OUTPUTS} <Yout[_N_,r]=col(‘output’||r)>;

* Define objective function ;
min obj = h;

* Define constrains;
con InpCon_inOri{i in INPUTS}:
sum{j in UNITS} L[j]*Xin[j,i] + Sin[i]=h*Xin[&j0,i];

con OutCon_inOri{r in OUTPUTS}:
sum{j in UNITS} L[j]*Yout[j,r] – Sout[r]=Yout[&j0,r];

* Define convexity constraints for VRS models;
/*con Convexity: sum{j in UNITS} L[j]=1;*/

* Solve the model;
solve ;

* Save the efficiency scores in a SAS dataset;
eff=h.sol;
DMUj0=DMUS[&j0];
create data solj0 from DMUj0 eff ;


*End of PROC OPTMODE;
quit;
%mend model_inOri;

%macro report;
* Delete previusly created datasets;
proc datasets nolist;
delete &_outdea1 &_outdea2;
run;

* Select the model and execute it for each unit of assessment;
%do j0=1 %to &_nUnits;
%if &_Orienta=”INPUT”
%then %do;
%model_inOri (&j0);
* Save the efficiency scores in a SAS dataset;
proc datasets nolist;
append base=&_outdea2=solj0;
run;
%end;
%else %do;
%model_outOri (&j0);
proc datasets nolist;
append base=&_outdea1 data=solj0;
run;
%end;
%end;

%if &_Orienta=”INPUT”
%then %do;
* Sort and print the results by efficiency score;
proc sort data=&_outdea2;
by eff;
run;
proc print data=&_outdea2;
run;

* Sort and print the results by unit name;
proc sort data=&_outdea2;
by DMUj0;
run;
proc print data=&_outdea2;
run;
%end;
%else %do;
* Sort and print the results by efficiency score;
proc sort data=&_outdea1;
by eff;
run;
proc print data=&_outdea1; title &_title;
run;

* Sort and print the results by unit name;
proc sort data=&_outdea1;
by DMUj0;
run;
proc print data=&_outdea1; title &_title;
run;
%end;

%mend report;

%macro ordea;
%data;
%report;
%mend ordea;

%ordea;


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

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

Leave a Reply