Bad dimension error when using gdxxrw

Hi everyone,

I am having a “Symbol: ZIMSAM2 Bad dimension: 1” error when importing a parameter into GAMS from Excel. See the code below:

PARAMETER ZIMSAM2(AC, ACP)
$call gdxxrw input="C:\Users\zimb_pan.xlsx" output="C:\Users\zimb_pan_sam.gdx" par=ZIMSAM2 rng=Sheet1!A1:AI35 rdim=1 cdim=1;

AC refers to every single variable in the model and ACP is an Alias for AC.
I understand that the error comes from cDim = 1 because when I increase cdim to a value x, the error message changes to Bad dimension:x.
Yet I know that labels are defined at column 1… So I am confused.

I joined the Excel file as an attachment.

Any help is appreciated!

Sarah
zimb_pan.xlsx (11.3 KB)

Hi Sarah
It looks like you haven’t defined AC yet. If I define the parameter PARAMETER ZIMSAM2(*, *) instead of PARAMETER ZIMSAM2(AC,ACP), the import runs fine.
Did you define/import AC before you want to import ZIMSAM2?
Hope this helps
Cheers
Renger

Hi Renger,
Thank you for this prompt reply. I did define AC previously, as well as ACP as an alias for AC. Furthermore, I can import all my data correctly if I enter it manually in the following way:

TABLE ZIMSAM2(AC,ACP)   8-SECTOR MICROSAM FOR ZIMBABWE ($Zim mill 1991)

              AAGEX       AAGFO       AAGOT       AMINE       ANAFO       ANAOI

CAGEX                                                       341.998    1135.653
CAGFO                                                       243.014
CAGOT         6.304                 244.130                 827.023     142.909
CMINE                                            91.141      39.080    1268.605

This is a subsection of the data, but it would be too long to enter all of it manually, hence my interest in uploading the data from Excel.

So my question is the following: I can write ZIMSAM2(AC, ACP) in a table and GAMS will recognize the parameter ZIMSAM2, as well as AC and ACP, but I don’t understand why GAMS won’t do the same if I import the data from Excel?

Thanks again!

Sarah

Hi Sarah,

You don’t need semicolons after “$”-statements.
Here GAMS gives the error: “ZIMSAM2 Bad dimension: 1;”
Drop the semicolon in “cdim=1;” and it should work fine.

Auke