Program 1.5


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

*Program 1.5: An example of PROC OPTMODEL using read statement;
data bankdata;

input Bank $ Labour Capital Profit;
datalines;
Bank1 10 2000 30
Bank2 50 40000 68
Bank3 8 25000 45
Bank4 18 70000 50
;

proc optmodel;


* Define parameters;

set <string> row ;
set <string> col ;
col={“Labour”, “Capital”, “Profit”};

number bankmatrix{r in row, c in col};
* Populating name of banks from the first column of the dataset to ‘row’;

read data bankdata
into row=[Bank] ;
* Populating value of Capital, Labour and Profit to each bank from the dataset;

read data bankdata
into
{r in row} <bankmatrix[r, “Labour”]=col(“Labour”)
bankmatrix[r, “Capital”]=col(“Capital”)
bankmatrix[r, “Profit”]=col(“Profit”)>;

* Printing bankmatrix;
print bankmatrix;

quit;

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

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

Leave a Reply