Export multiple variables from GAMS to Excel using GDX utilities

Dear friends:

I wonder how to export many variables from GAMS to one Excel file using GDX utilities.

I know that the following command allows exporting one variable from GAMS to GDX:

execute_unload “results1.gdx” A.L

execute ‘gdxxrw.exe results1.gdx var=A.L’

How to do if I want to export many variables to one excel file?

Thanks a lot.


Taher


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hi Taber



There are several options:

  •      Write everything in one long line (which is quite cumbersome).
    
  •      Use the on/offecho  technique:
    

For example

$onecho > taskout.txt

par = results_r rng=results_r!a2 rdim=4

par = results_gdp rng=results_gdp!a2 rdim=4

par = results_r_row rng=results_r_row!a2 rdim=5

par = results_r_h rng=results_r_h!a2 rdim=5

$offecho



This writes the text between the $onecho and $offecho to the file taskout.txt

After this you write them to the excel file using



execute 'gdxxrw.exe o=results.xlsx i=results.gdx @taskout.txt’

  •      The third option is writing the information in the Excel file itself and point the gdxxrw command to the range where this information can be found.
    




These 3 options are well described in the documentation (gdxutils.pdf)



Cheers



Renger


\


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch










\




From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Taher kahil
Sent: Thursday, November 13, 2014 14:19
To: gamsworld@googlegroups.com
Subject: Export multiple variables from GAMS to Excel using GDX utilities



Dear friends:



I wonder how to export many variables from GAMS to one Excel file using GDX utilities.



I know that the following command allows exporting one variable from GAMS to GDX:



execute_unload “results1.gdx” A.L



execute ‘gdxxrw.exe results1.gdx var=A.L’



How to do if I want to export many variables to one excel file?



Thanks a lot.





Taher


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Thank you very much Renger. The following option worked very well for me:

execute_unload “filename.gdx” variable1.L,variable2.L,variable3.L,variable4.L;

execute ‘gdxxrw.exe filename.gdx var=variable1.L rng=A1 var=variable2.L rng=A14 var=variable3.L rng=A46 var=variable4.L rng=A81’;


Cheers,


Taher





Le jeudi 13 novembre 2014 14:18:32 UTC+1, Taher kahil a écrit :

Dear friends:

I wonder how to export many variables from GAMS to one Excel file using GDX utilities.

I know that the following command allows exporting one variable from GAMS to GDX:

execute_unload “results1.gdx” A.L

execute ‘gdxxrw.exe results1.gdx var=A.L’

How to do if I want to export many variables to one excel file?

Thanks a lot.


Taher


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.