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
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
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.