Hi dear all,
I want to read an excel sheet in GAMS. the file contains series of 500 values per year for each variable a,b and c. it is a parameter that I define as Stk(yr,i,se). The values are saved in an excel sheet with 3 dimensions Rdim=2 Cdim=1 like the following example
1 2 3 …500
a y1
a y2
…
a y10
b y1
b y2
…
b y10
…
So I proceed this way (see code below) but it couldn´t work out . the erroe messages are:
140 Unknown symbol (related to ‘a’ in the following declaration ----->Randomdata(‘a’,Yr,Se) = Rdata(‘Maize’,Yrn0,Se) ;
149 Uncontrolled set entered as constant (related to ‘Se’ in the following declaration ----->Randomdata(‘a’,Yr,Se) = Rdata(‘Maize’,Yrn0,Se)).
But before that they was an error related to the lign (execute 'gdxxrw.exe…), I think that it was not well stated.
Please provide some hints. Thanks for your consideration
[/
Se series of stochastic yield term /1*500/
i products / a,b,c /
Yr year / 2014*2025/
t0(Yr) Year 0
tl(Yr) Last year
Yrn0(Yr) time path /2014*2025/
ti(Yrn0) first year for considered time frame
tf(Yrn0) final year for considered time frame
crop for data calculations /a,b,c/
Parameter
Stk(Yr,i,Se)
* read data from Excel
execute 'gdxxrw.exe i="stochastic yields.xlsx" o=Randomdata.gdx par=Rdata rng=Sample!A1 Rdim=2 Cdim=1 MaxDupeErrors = <500> ';
execute_load 'Randomdata.gdx', Rdata;
Display Rdata ;
* stochastic yield data
Randomdata('a',Yr,Se) = Rdata('Maize',Yrn0,Se) ;
Randomdata('b',Yr,Se) = Rdata('Rice',Yrn0,Se) ;
Randomdata('c',Yr,Se) = Rdata('Sorghum',Yrn0,Se) ;
*Assign values
stk('Yr0',i,Se)= 0 ;
STK(Yr,i,Se)= Rdata(crop,Yrn0,Se) ;]