Import a text file

Problems with syntax of GAMS
Post Reply
nik
User
User
Posts: 1
Joined: 2 years ago

Import a text file

Post by nik »

Hi, I am a new user in gams and I am trying to import a txt file, but I get the same errors (error 140 & error 36) in the first lines of my txt file again and again.
Could anyone help?

My code goes like this, and I have also attached the txt file

* define the set of asset classes

set n Number of returns /n1*n120/;

* define Tables, Parameters, Scalars

Scalar T /120/;


$INCLUDE prices.txt
prices.txt
(1.04 KiB) Downloaded 111 times
GFA
User
User
Posts: 50
Joined: 5 years ago

Re: Import a text file

Post by GFA »

Hi,

You need to declare your parameter (put "parameter" in front). Also, add the set-elements on the same row as the values, then GAMS knows which values belong to which set-elements.

Code: Select all

parameter prices(n)/
n1     4522,
n2     4395
/;
See also: https://www.gams.com/35/docs/UG_DataEntry.html section Parameters.

Cheers,
GFA
Post Reply