User Tools

Site Tools


How do I export all elements of parameter (including Zeros) from GAMS into Excel?

GAMS only generates entries in a GDX file for those parameters, which are not equal to Zero or to their default values. A Zero will not be stored. However, we can tell GAMS to store an EPS (Epsilon) instead and instruct GDXXRW to use a Zero when writing the value for 'Epsilon'.

Below you find an example, which also shows an alternative approach regarding variables:

$eolcom #
set i    /i1*i10/;
parameter x(i);
variable  y(i);
x(i) = uniformint(0,1);
y.m(i) = 1;                 #Generate entries for all variable attributes
y.l(i) = x(i);
x(i)$(not x(i)) = eps;      # Assign Eps to x(i) = 0
Execute_Unload 'results.gdx',x,y;
$onecho >param.txt
EpsOut =0 par =x   rng =a1
sq =n     var =y   rng =a4
Execute 'GDXXRW.EXE results.gdx @param.txt' ;

gams/export_all_elements_of_parameter_including_zeros_from_gams_into_excel.txt · Last modified: 2008/06/17 13:34 by support