Exercise 9.3

/***********************************************************************************
* 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 Malmquist Productivity Index and its Components: solution to exercise 9.3;
option nodate ;
%let _title=’Malmquist Productivity Index and its Components: solution to exercise 9.3′;
%let _InData_P1=’C:\sasor\Data9_3_In_P1_exercise.txt’;
%let _OutData_P1=’C:\sasor\Data9_3_Out_P1_exercise.txt’;
%let _InData_P2=’C:\sasor\Data9_3_In_P2_exercise.txt’;
%let _OutData_P2=’C:\sasor\Data9_3_Out_P2_exercise.txt’;
%let _nInput=2;
%let _nOutput=2;
%let _nUnits=10;
%let _outMalm1=outMalm1;
%let _outMalm2=outMalm2;
%let _Orienta=’INPUTMIN’; * Alternative selection is ‘OUTPUTMAX’;

%macro importdata (txtFile, sasFile);
proc import
datafile=&txtFile
out=&sasFile
dbms=tab
replace;
getnames=yes;
run;
%mend importdata;

* The data handling macro;
%macro data;
* Import text tab delimited input variables to SAS data file, period1;
%importdata(&_InData_P1,data9_3_input_P1);
* Import text tab delimited output variables to SAS data file, period1;
%importdata(&_OutData_P1,data9_3_output_P1);
* Import text tab delimited input variables to SAS data file, period2;
%importdata(&_InData_P2,data9_3_input_P2);
* Import text tab delimited output variables to SAS data file, period2;
%importdata(&_OutData_P2,data9_3_output_P2);
%mend data;

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

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

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

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

* Load matrix of input variables;
read data data9_3_input_P1
into [_N_]
{i in INPUTS} ;

* Load matrix of input variables;
read data data9_3_input_P2
into [_N_]
{i in INPUTS} ;

* Load matrix of input variables;
read data data9_3_output_P1
into [_N_]
{r in OUTPUTS} ;

* Load matrix of input variables;
read data data9_3_output_P2
into [_N_]
{r in OUTPUTS} ;

* Define objective function ;
max obj = h;

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

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

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

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

%macro report(per1,per2);
* Select the model and execute it for each unit of assessment;
%do j0=1 %to &_nUnits;
%model_outOri (&per1,&per2,&j0);
* Save the results for report writing;
proc datasets nolist;
append base=&_outMalm1 data=solj0;
run;
%end;
%mend report;

%macro ormalm;
%data;
* Delete previously created datasets;
proc datasets nolist;
delete &_outMalm1;
run;

%report(1,1);
%report(2,2);
%report(1,2);
%report(2,1);

data &_outMalm2;
merge &_outMalm1(WHERE=(p1=1 and p2=1) RENAME=(eff=DEA11))
&_outMalm1(WHERE=(p1=1 and p2=2) RENAME=(eff=DEA12))
&_outMalm1(WHERE=(p1=2 and p2=1) RENAME=(eff=DEA21))
&_outMalm1(WHERE=(p1=2 and p2=2) RENAME=(eff=DEA22));
by dmuj0;
drop p1 p2;
run;

data &_outMalm2(drop=DEA21 DEA12 rename=(DEA11=EffPeriod1 DEA22=EffPeriod2));
set &_outMalm2;
EffChange=DEA22/DEA11;
TechChange=sqrt((DEA12*DEA11)/(DEA22*DEA21));
MalmIndex=EffChange*TechChange;
run;

proc print; run;

%mend ormalm;

%ormalm;


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

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

Leave a Reply