GDXXRWExample7.gms : Reads a four dimensional parameter from an MS Excel file and writes it to a GDX file


This program illustrates reading a four dimensional parameter.

Category : GAMS Data Utilities library

Main file : GDXXRWExample7.gms   includes :  Test1.xls  GDXXRWExample7.gms


This program illustrates reading a four dimensional parameter.


$if %system.filesys% == UNIX $abort.noerror 'This model cannot run on a non-Windows platform';
$call msappavail -Excel
$if errorlevel 1 $abort.noerror 'Microsoft Excel is not available!';

 sets a  first row entries     /a1,a2/
      b  second row entries    /b1,b2/
      q  first column entries  /q1,q2/
      r  second column entries /r1,r2/ ;

 parameter data3(a,b,q,r);

$CALL GDXXRW Test1.xls par=data3 rng=EX3!A1:F6 Rdim=2 Cdim=2 trace=0
$GDXIN Test1.gdx
$LOAD data3

display data3;

* Data Validation
parameter exp_data3(a,b,q,r) expected_data3 /
a1.b1.q1.r1  1
a1.b1.q1.r2  2
a1.b1.q2.r1  3
a1.b1.q2.r2  4
a1.b2.q1.r1  5
a1.b2.q1.r2  6
a1.b2.q2.r1  7
a1.b2.q2.r2  8
a2.b1.q1.r1  9
a2.b1.q1.r2 10
a2.b1.q2.r1 11
a2.b1.q2.r2 12
a2.b2.q1.r1 13
a2.b2.q1.r2 14
a2.b2.q2.r1 15
a2.b2.q2.r2 16
set error01(a,b,q,r) unexpected value;
error01(a,b,q,r) = exp_data3(a,b,q,r)<>data3(a,b,q,r);
abort$card(error01) error01;