Write multiple variables from gams to excel in one statement

dear all

I have a question and I appreciate any suggestion.

I want to write the value of about 30 variables from gams to excel.
How can I do it with one statement.
I currently use execute_unload to make a gdx file
and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.

How can I do it?

Regards,

\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran
www.babaksp.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi Bob

Why don’t you use code like this (assuming that all your data is in mydata.gdx and you want to write your data to mydata.xlsx):



$onecho > taskout.txt

var=x.l rng=results!a1 rdim=1 cdim=1

var=y.l rng=results!a100 rdim=1 cdim=1

…

…

$offecho



execute ‘gdxxrw.exe i=mydata.gdx o=mydata.xlsx @taskout.txt trace=3’ ;



See the gdx manual for more examples.

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 Bob Pay
Sent: Dienstag, 4. Dezember 2012 21:11
To: gamsworld
Subject: Write multiple variables from gams to excel in one statement



dear all



I have a question and I appreciate any suggestion.



I want to write the value of about 30 variables from gams to excel.

How can I do it with one statement.

I currently use execute_unload to make a gdx file

and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.



How can I do it?



Regards,



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Dear Babak,

This is an a example to how I extract data to the excel file.

This way each parameter is in a different sheet.



Code:

execute_UNLOAD ‘calib.gdx’ YB,CALIBCROPPROFIT,OBSCROPPROFIT,LAND,CONSTRAINTS;

execute ‘gdxxrw calib.gdx output=ModelOutput2002US.xls par=YB rng=YB!A1 rdim=1 par=CALIBCROPPROFIT rng=CALIBCROPPROFIT!A1 rdim=1 par=OBSCROPPROFIT rng=OBSCROPPROFIT!A1 rdim=1’;

execute 'gdxxrw calib.gdx output=ModelOutput2002US.xls par=LAND rng=LAND!A1 rdim=1 par=CONSTRAINTS rng=CONSTRAINTS!A1 rdim=1 ';



Hope it helps,

Mickey.







Mickey Rapaport-Rom

PhD Student

Researcher at the Natural Resources and Environmental Research Center

University of Haifa

Mail address: raprom01@gmail.com





From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Bob Pay
Sent: Tuesday, December 04, 2012 10:11 PM
To: gamsworld
Subject: Write multiple variables from gams to excel in one statement



dear all



I have a question and I appreciate any suggestion.



I want to write the value of about 30 variables from gams to excel.

How can I do it with one statement.

I currently use execute_unload to make a gdx file

and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.



How can I do it?



Regards,



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Dear Mickey

Thank you so much

I did not know how to use $onecho and $offecho. Now that you and Jose send me some examples, I can use it.

I don’t know why, but when I use ?codes like this:
execute ‘gdxxrw calib.gdx output=ModelOutput2002US.xls par=YB rng=YB!A1 rdim=1 par=CALIBCROPPROFIT rng=CALIBCROPPROFIT!A1 rdim=1 par=OBSCROPPROFIT rng=OBSCROPPROFIT!A1 rdim=1’;

It always write the first variable in excel and skip rest of them, I don’t know why

But now I should try it again with your hints.

I have a pdf file about gdx, but it does not discuss your first example!

Thank you again


On Wed, Dec 5, 2012 at 11:08 AM, Mickey Rapaport-Rom wrote:

Dear Babak,

This is an a example to how I extract data to the excel file.

This way each parameter is in a different sheet.



Code:

execute_UNLOAD ‘calib.gdx’ YB,CALIBCROPPROFIT,OBSCROPPROFIT,LAND,CONSTRAINTS;

execute ‘gdxxrw calib.gdx output=ModelOutput2002US.xls par=YB rng=YB!A1 rdim=1 par=CALIBCROPPROFIT rng=CALIBCROPPROFIT!A1 rdim=1 par=OBSCROPPROFIT rng=OBSCROPPROFIT!A1 rdim=1’;

execute 'gdxxrw calib.gdx output=ModelOutput2002US.xls par=LAND rng=LAND!A1 rdim=1 par=CONSTRAINTS rng=CONSTRAINTS!A1 rdim=1 ';



Hope it helps,

Mickey.







Mickey Rapaport-Rom

PhD Student

Researcher at the Natural Resources and Environmental Research Center

University of Haifa

Mail address: raprom01@gmail.com





From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Bob Pay
Sent: Tuesday, December 04, 2012 10:11 PM

To: gamsworld
Subject: Write multiple variables from gams to excel in one statement



dear all



I have a question and I appreciate any suggestion.



I want to write the value of about 30 variables from gams to excel.

How can I do it with one statement.

I currently use execute_unload to make a gdx file

and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.



How can I do it?



Regards,



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran
www.babaksp.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Dear Renger
Thank you for your answer

It is very helpful. Do you have any document about it? I don’t know any thing about the use of $onecho and $offecho (I know that it does not related to gdx, but I want to know more). Does McCarl discuss these issues in his book?

Thank you


On Wed, Dec 5, 2012 at 10:49 AM, Renger van Nieuwkoop wrote:

Hi Bob

Why don’t you use code like this (assuming that all your data is in mydata.gdx and you want to write your data to mydata.xlsx):



$onecho > taskout.txt

var=x.l rng=results!a1 rdim=1 cdim=1

var=y.l rng=results!a100 rdim=1 cdim=1

…

…

$offecho



execute ‘gdxxrw.exe i=mydata.gdx o=mydata.xlsx @taskout.txt trace=3’ ;



See the gdx manual for more examples.

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 Bob Pay
Sent: Dienstag, 4. Dezember 2012 21:11

To: gamsworld
Subject: Write multiple variables from gams to excel in one statement



dear all



I have a question and I appreciate any suggestion.



I want to write the value of about 30 variables from gams to excel.

How can I do it with one statement.

I currently use execute_unload to make a gdx file

and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.



How can I do it?



Regards,



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran
www.babaksp.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Dear Bob,

It will write to the excel only if it a parameter.

I mean that if it is, for example, a variable, you can’t write to the excel XXXXX.L.

You need to define a new parameter and then write the new one to the excel.



For example, if I have a variable NX and I want the result in excel, this is the code:



POSITIVE VARIABLE NX;



PARAMETER

LAND(I,G) ALLOCATED LAND;



LAND(I,G) = NX.L(I,G);



execute_UNLOAD ‘calib.gdx’ LAND;

execute 'gdxxrw calib.gdx output=ModelOutput2002US.xls par=LAND rng=LAND!A1 rdim=1 ';



Mickey.





From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Bob Pay
Sent: Wednesday, December 05, 2012 12:40 PM
To: gamsworld
Subject: Re: Write multiple variables from gams to excel in one statement



Dear Mickey



Thank you so much



I did not know how to use $onecho and $offecho. Now that you and Jose send me some examples, I can use it.



I don’t know why, but when I use ?codes like this:

execute ‘gdxxrw calib.gdx output=ModelOutput2002US.xls par=YB rng=YB!A1 rdim=1 par=CALIBCROPPROFIT rng=CALIBCROPPROFIT!A1 rdim=1 par=OBSCROPPROFIT rng=OBSCROPPROFIT!A1 rdim=1’;



It always write the first variable in excel and skip rest of them, I don’t know why



But now I should try it again with your hints.



I have a pdf file about gdx, but it does not discuss your first example!



Thank you again



On Wed, Dec 5, 2012 at 11:08 AM, Mickey Rapaport-Rom wrote:

Dear Babak,

This is an a example to how I extract data to the excel file.

This way each parameter is in a different sheet.



Code:

execute_UNLOAD ‘calib.gdx’ YB,CALIBCROPPROFIT,OBSCROPPROFIT,LAND,CONSTRAINTS;

execute ‘gdxxrw calib.gdx output=ModelOutput2002US.xls par=YB rng=YB!A1 rdim=1 par=CALIBCROPPROFIT rng=CALIBCROPPROFIT!A1 rdim=1 par=OBSCROPPROFIT rng=OBSCROPPROFIT!A1 rdim=1’;

execute 'gdxxrw calib.gdx output=ModelOutput2002US.xls par=LAND rng=LAND!A1 rdim=1 par=CONSTRAINTS rng=CONSTRAINTS!A1 rdim=1 ';



Hope it helps,

Mickey.







Mickey Rapaport-Rom

PhD Student

Researcher at the Natural Resources and Environmental Research Center

University of Haifa

Mail address: raprom01@gmail.com





From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Bob Pay
Sent: Tuesday, December 04, 2012 10:11 PM


To: gamsworld
Subject: Write multiple variables from gams to excel in one statement



dear all



I have a question and I appreciate any suggestion.



I want to write the value of about 30 variables from gams to excel.

How can I do it with one statement.

I currently use execute_unload to make a gdx file

and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.



How can I do it?



Regards,



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.




\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

So the problem is variable and I should use a parameter instead.
wonderful

why the don’t make it easier…!?

Thank you Mickey. Now I understand what my problem is.
Thank you so much


On Wed, Dec 5, 2012 at 2:49 PM, Mickey Rapaport-Rom wrote:

Dear Bob,

It will write to the excel only if it a parameter.

I mean that if it is, for example, a variable, you can’t write to the excel XXXXX.L.

You need to define a new parameter and then write the new one to the excel.



For example, if I have a variable NX and I want the result in excel, this is the code:



POSITIVE VARIABLE NX;



PARAMETER

LAND(I,G) ALLOCATED LAND;



LAND(I,G) = NX.L(I,G);



execute_UNLOAD ‘calib.gdx’ LAND;

execute 'gdxxrw calib.gdx output=ModelOutput2002US.xls par=LAND rng=LAND!A1 rdim=1 ';



Mickey.





From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Bob Pay
Sent: Wednesday, December 05, 2012 12:40 PM
To: gamsworld
Subject: Re: Write multiple variables from gams to excel in one statement



Dear Mickey



Thank you so much



I did not know how to use $onecho and $offecho. Now that you and Jose send me some examples, I can use it.



I don’t know why, but when I use ?codes like this:

execute ‘gdxxrw calib.gdx output=ModelOutput2002US.xls par=YB rng=YB!A1 rdim=1 par=CALIBCROPPROFIT rng=CALIBCROPPROFIT!A1 rdim=1 par=OBSCROPPROFIT rng=OBSCROPPROFIT!A1 rdim=1’;



It always write the first variable in excel and skip rest of them, I don’t know why



But now I should try it again with your hints.



I have a pdf file about gdx, but it does not discuss your first example!



Thank you again



On Wed, Dec 5, 2012 at 11:08 AM, Mickey Rapaport-Rom wrote:

Dear Babak,

This is an a example to how I extract data to the excel file.

This way each parameter is in a different sheet.



Code:

execute_UNLOAD ‘calib.gdx’ YB,CALIBCROPPROFIT,OBSCROPPROFIT,LAND,CONSTRAINTS;

execute ‘gdxxrw calib.gdx output=ModelOutput2002US.xls par=YB rng=YB!A1 rdim=1 par=CALIBCROPPROFIT rng=CALIBCROPPROFIT!A1 rdim=1 par=OBSCROPPROFIT rng=OBSCROPPROFIT!A1 rdim=1’;

execute 'gdxxrw calib.gdx output=ModelOutput2002US.xls par=LAND rng=LAND!A1 rdim=1 par=CONSTRAINTS rng=CONSTRAINTS!A1 rdim=1 ';



Hope it helps,

Mickey.







Mickey Rapaport-Rom

PhD Student

Researcher at the Natural Resources and Environmental Research Center

University of Haifa

Mail address: raprom01@gmail.com





From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Bob Pay
Sent: Tuesday, December 04, 2012 10:11 PM


To: gamsworld
Subject: Write multiple variables from gams to excel in one statement



dear all



I have a question and I appreciate any suggestion.



I want to write the value of about 30 variables from gams to excel.

How can I do it with one statement.

I currently use execute_unload to make a gdx file

and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.



How can I do it?



Regards,



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.




\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran
www.babaksp.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi Bob

See chapter 13.2.3.51Onecho and Offecho

Cheers

Renger



Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von Bob Pay
Gesendet: Mittwoch, 5. Dezember 2012 11:43
An: gamsworld
Betreff: Re: Write multiple variables from gams to excel in one statement



Dear Renger

Thank you for your answer



It is very helpful. Do you have any document about it? I don’t know any thing about the use of $onecho and $offecho (I know that it does not related to gdx, but I want to know more). Does McCarl discuss these issues in his book?



Thank you



On Wed, Dec 5, 2012 at 10:49 AM, Renger van Nieuwkoop wrote:

Hi Bob

Why don’t you use code like this (assuming that all your data is in mydata.gdx and you want to write your data to mydata.xlsx):



$onecho > taskout.txt

var=x.l rng=results!a1 rdim=1 cdim=1

var=y.l rng=results!a100 rdim=1 cdim=1

…

…

$offecho



execute ‘gdxxrw.exe i=mydata.gdx o=mydata.xlsx @taskout.txt trace=3’ ;



See the gdx manual for more examples.

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 Bob Pay
Sent: Dienstag, 4. Dezember 2012 21:11


To: gamsworld
Subject: Write multiple variables from gams to excel in one statement



dear all



I have a question and I appreciate any suggestion.



I want to write the value of about 30 variables from gams to excel.

How can I do it with one statement.

I currently use execute_unload to make a gdx file

and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.



How can I do it?



Regards,



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.




\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

so many thanks


On Wed, Dec 5, 2012 at 3:30 PM, Renger van Nieuwkoop wrote:

Hi Bob

See chapter 13.2.3.51Onecho and Offecho

Cheers

Renger



Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von Bob Pay
Gesendet: Mittwoch, 5. Dezember 2012 11:43
An: gamsworld
Betreff: Re: Write multiple variables from gams to excel in one statement



Dear Renger

Thank you for your answer



It is very helpful. Do you have any document about it? I don’t know any thing about the use of $onecho and $offecho (I know that it does not related to gdx, but I want to know more). Does McCarl discuss these issues in his book?



Thank you



On Wed, Dec 5, 2012 at 10:49 AM, Renger van Nieuwkoop wrote:

Hi Bob

Why don’t you use code like this (assuming that all your data is in mydata.gdx and you want to write your data to mydata.xlsx):



$onecho > taskout.txt

var=x.l rng=results!a1 rdim=1 cdim=1

var=y.l rng=results!a100 rdim=1 cdim=1

…

…

$offecho



execute ‘gdxxrw.exe i=mydata.gdx o=mydata.xlsx @taskout.txt trace=3’ ;



See the gdx manual for more examples.

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 Bob Pay
Sent: Dienstag, 4. Dezember 2012 21:11


To: gamsworld
Subject: Write multiple variables from gams to excel in one statement



dear all



I have a question and I appreciate any suggestion.



I want to write the value of about 30 variables from gams to excel.

How can I do it with one statement.

I currently use execute_unload to make a gdx file

and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.



How can I do it?



Regards,



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.




\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran
www.babaksp.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

The whole process of To write the value of variables from excel to gams and vice versa:

To write the value of variables from excel to gams:
table a(i,j)
$call=xls2gms I=“c:/Documents and settings/mr peter/
Desktop/book1.xls” r=sheet2! O=book1.inc;
$include book1.inc;

To write the value of variables from gams to excel:
execute_unload “results.gdx” x.L x.M
execute ‘gdxxrw.exe results.gdx var=x.L’
rng=Newsheet!f1:i4’ execute 'gdxxrw.exe results.gdx var=x.M

As x.L, the first command, the first place to start filling it in Excel’s cells and x.M, will determine Block f1:i4 in Excel.

Good luck
N.Hosseini



On Tuesday, December 4, 2012 4:11:19 PM UTC-4, B.Saleckpay wrote:

dear all

I have a question and I appreciate any suggestion.

I want to write the value of about 30 variables from gams to excel.
How can I do it with one statement.
I currently use execute_unload to make a gdx file
and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.

How can I do it?

Regards,

\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran
www.babaksp.com


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/g7q1yWaYpEYJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Dear Negin

So many thanks for your mail.
I know how to use gdxxrw but:


First) I did not know about “Newsheet”? Does it make a new sheet in excel file?
Two) My main problem is to write all variable in file using one execute gdxxrw statement?
Three) even for one statement, when there is so many variables, I cant break the statement to two ore more line?
Four) when I use gdxxrw to write the value of two variables in one statement, only the value of the second variables is written and I don’t know why?





On Sun, Dec 9, 2012 at 10:15 PM, Negin Hosseini wrote:

The whole process of To write the value of variables from excel to gams and vice versa:

To write the value of variables from excel to gams:
table a(i,j)
$call=xls2gms I=“c:/Documents and settings/mr peter/
Desktop/book1.xls” r=sheet2! O=book1.inc;
$include book1.inc;

To write the value of variables from gams to excel:
execute_unload “results.gdx” x.L x.M
execute ‘gdxxrw.exe results.gdx var=x.L’
rng=Newsheet!f1:i4’ execute 'gdxxrw.exe results.gdx var=x.M

As x.L, the first command, the first place to start filling it in Excel’s cells and x.M, will determine Block f1:i4 in Excel.

Good luck
N.Hosseini



On Tuesday, December 4, 2012 4:11:19 PM UTC-4, B.Saleckpay wrote:

dear all

I have a question and I appreciate any suggestion.

I want to write the value of about 30 variables from gams to excel.
How can I do it with one statement.
I currently use execute_unload to make a gdx file
and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.

How can I do it?

Regards,

\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran
www.babaksp.com


To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/g7q1yWaYpEYJ.

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran
www.babaksp.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Dear Bob



It is getting a little boring, but perhaps you should read my post of this week on rules in the mailing list before you post an E-Mail like yours…



So I just repeat:

  •      Search the mailing list: Your question on writing all variables  using one execute gdxxrw statement was even answered in this topic discussion…
    
  •      RTFM:  There is a manual on using GDX. If you would have read it, then you would see that newsheet is not creating a new sheet but just a name as well on how to use GDXXRW for writing these commands.
    




Cheers



Renger





Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von Bob Pay
Gesendet: Dienstag, 11. Dezember 2012 11:38
An: gamsworld




Betreff: Re: Write multiple variables from gams to excel in one statement



Dear Negin

So many thanks for your mail.
I know how to use gdxxrw but:


First) I did not know about “Newsheet”? Does it make a new sheet in excel file?
Two) My main problem is to write all variable in file using one execute gdxxrw statement?
Three) even for one statement, when there is so many variables, I cant break the statement to two ore more line?
Four) when I use gdxxrw to write the value of two variables in one statement, only the value of the second variables is written and I don’t know why?




On Sun, Dec 9, 2012 at 10:15 PM, Negin Hosseini wrote:

The whole process of To write the value of variables from excel to gams and vice versa:



To write the value of variables from excel to gams:

table a(i,j)

$call=xls2gms I="c:/Documents and settings/mr peter/

Desktop/book1.xls" r=sheet2! O=book1.inc;

$include book1.inc;



To write the value of variables from gams to excel:

execute_unload “results.gdx” x.L x.M

execute ‘gdxxrw.exe results.gdx var=x.L’

rng=Newsheet!f1:i4’ execute 'gdxxrw.exe results.gdx var=x.M



As x.L, the first command, the first place to start filling it in Excel’s cells and x.M, will determine Block f1:i4 in Excel.



Good luck

N.Hosseini





On Tuesday, December 4, 2012 4:11:19 PM UTC-4, B.Saleckpay wrote:

dear all



I have a question and I appreciate any suggestion.



I want to write the value of about 30 variables from gams to excel.

How can I do it with one statement.

I currently use execute_unload to make a gdx file

and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.



How can I do it?



Regards,



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/g7q1yWaYpEYJ.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

dear Renger

Thank you for your alarm…!

I have read gdx manual ( also not completely) and of course I have got my answer in this discussion about writing and etc.
So, I did not want to keep on discussion aimlessly until Negin sent an answer. I only wanted to mention that my problem was something else; and bout “Newsheet”, it was a little weird to be a generic name for new sheet while mostly it is used as Sheet# so I just got mixed up.

Thank you anyway and be sure no more useless mail you will get from me.

bests,




On Tue, Dec 11, 2012 at 2:26 PM, Renger van Nieuwkoop wrote:

Dear Bob



It is getting a little boring, but perhaps you should read my post of this week on rules in the mailing list before you post an E-Mail like yours…



So I just repeat:

  •      Search the mailing list: Your question on writing all variables  using one execute gdxxrw statement was even answered in this topic discussion…
    
  •      RTFM:  There is a manual on using GDX. If you would have read it, then you would see that newsheet is not creating a new sheet but just a name as well on how to use GDXXRW for writing these commands.
    




Cheers



Renger





Von: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] Im Auftrag von Bob Pay
Gesendet: Dienstag, 11. Dezember 2012 11:38
An: gamsworld




Betreff: Re: Write multiple variables from gams to excel in one statement



Dear Negin

So many thanks for your mail.
I know how to use gdxxrw but:


First) I did not know about “Newsheet”? Does it make a new sheet in excel file?
Two) My main problem is to write all variable in file using one execute gdxxrw statement?
Three) even for one statement, when there is so many variables, I cant break the statement to two ore more line?
Four) when I use gdxxrw to write the value of two variables in one statement, only the value of the second variables is written and I don’t know why?




On Sun, Dec 9, 2012 at 10:15 PM, Negin Hosseini wrote:

The whole process of To write the value of variables from excel to gams and vice versa:



To write the value of variables from excel to gams:

table a(i,j)

$call=xls2gms I="c:/Documents and settings/mr peter/

Desktop/book1.xls" r=sheet2! O=book1.inc;

$include book1.inc;



To write the value of variables from gams to excel:

execute_unload “results.gdx” x.L x.M

execute ‘gdxxrw.exe results.gdx var=x.L’

rng=Newsheet!f1:i4’ execute 'gdxxrw.exe results.gdx var=x.M



As x.L, the first command, the first place to start filling it in Excel’s cells and x.M, will determine Block f1:i4 in Excel.



Good luck

N.Hosseini





On Tuesday, December 4, 2012 4:11:19 PM UTC-4, B.Saleckpay wrote:

dear all



I have a question and I appreciate any suggestion.



I want to write the value of about 30 variables from gams to excel.

How can I do it with one statement.

I currently use execute_unload to make a gdx file

and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.



How can I do it?



Regards,



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/g7q1yWaYpEYJ.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran
www.babaksp.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Sorry I I not understood!
But You can organize output for variable too
Just type instead par= var=
sorry If I not understood correctly

05.12.2012, 15:20, “Mickey Rapaport-Rom” :

Dear Bob,

It will write to the excel only if it a parameter.

I mean that if it is, for example, a variable, you can’t write to the excel XXXXX.L.

You need to define a new parameter and then write the new one to the excel.

For example, if I have a variable NX and I want the result in excel, this is the code:

POSITIVE VARIABLE NX;

PARAMETER

          LAND(I,G)             ALLOCATED LAND;



            LAND(I,G) = NX.L(I,G);

execute_UNLOAD ‘calib.gdx’ LAND;

execute 'gdxxrw calib.gdx output=ModelOutput2002US.xls par=LAND rng=LAND!A1 rdim=1 ';

Mickey.

From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Bob Pay
Sent: Wednesday, December 05, 2012 12:40 PM
To: gamsworld
Subject: Re: Write multiple variables from gams to excel in one statement

Dear Mickey

Thank you so much

I did not know how to use $onecho and $offecho. Now that you and Jose send me some examples, I can use it.

I don’t know why, but when I use ?codes like this:

execute ‘gdxxrw calib.gdx output=ModelOutput2002US.xls par=YB rng=YB!A1 rdim=1 par=CALIBCROPPROFIT rng=CALIBCROPPROFIT!A1 rdim=1 par=OBSCROPPROFIT rng=OBSCROPPROFIT!A1 rdim=1’;

It always write the first variable in excel and skip rest of them, I don’t know why

But now I should try it again with your hints.

I have a pdf file about gdx, but it does not discuss your first example!

Thank you again

On Wed, Dec 5, 2012 at 11:08 AM, Mickey Rapaport-Rom wrote:

Dear Babak,

This is an a example to how I extract data to the excel file.

This way each parameter is in a different sheet.

Code:

execute_UNLOAD ‘calib.gdx’ YB,CALIBCROPPROFIT,OBSCROPPROFIT,LAND,CONSTRAINTS;

execute ‘gdxxrw calib.gdx output=ModelOutput2002US.xls par=YB rng=YB!A1 rdim=1 par=CALIBCROPPROFIT rng=CALIBCROPPROFIT!A1 rdim=1 par=OBSCROPPROFIT rng=OBSCROPPROFIT!A1 rdim=1’;

execute 'gdxxrw calib.gdx output=ModelOutput2002US.xls par=LAND rng=LAND!A1 rdim=1 par=CONSTRAINTS rng=CONSTRAINTS!A1 rdim=1 ';

Hope it helps,

Mickey.

Mickey Rapaport-Rom

PhD Student

Researcher at the Natural Resources and Environmental Research Center

University of Haifa

Mail address: raprom01@gmail.com

From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Bob Pay
Sent: Tuesday, December 04, 2012 10:11 PM

To: gamsworld
Subject: Write multiple variables from gams to excel in one statement

dear all

I have a question and I appreciate any suggestion.

I want to write the value of about 30 variables from gams to excel.

How can I do it with one statement.

I currently use execute_unload to make a gdx file

and then use gdxrrw to write from gdx file to excel, but I can not write all variables in one statement.

How can I do it?

Regards,


Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran

www.babaksp.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

With kindly regards!
Andre Savitsky
E-mail:andresavit@yandex.ru
andre_savit@yahoo.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.