Unloading the set from GAMS

Top  Previous  Next

Getting a set to the spreadsheet from a GDX file is also only half the battle.  One must also use commands in GAMS to place the data into the GDX file as discussed in the chapter Using GAMS Data Exchange or GDX Files.  This should generally not be done at compile time so one should only use the execute command as follows following (Gdxxrwwrite.gms)

 

Execute_unload ' ' threedim,i,j,k,ii;

execute "Gdxxrw Gdxxrwwrite.gdx o=gdxxrwss.xls set=i Rng=output2!a1  cdim=1 "

 

where the Execute_Unload tells what data to place in the GDX file and identifies the GDX source file name.  The matching gdwxrw execution tells the name of the GDX file, the name of the spreadsheet and identifies the data to unload.

Notes:

Either the row or the column dimension (Rdim or Cdim) should be set to '1' to specify a row or column for the set.
One must be careful when using Gdxxrw as each time the command is executed the GDX file is erased and only has the current contents and thus should be written just before if reusing the name.