Element name rules

Top  Previous  Next

Set or Sets statements declare names for individual set elements.  These element names must follow a set of rules.  An element name

Can be up to 63  characters long.
Should try to attain unique identification in the first 10 characters since longer names will be truncated to 10 characters in certain displays.
Must start with an alphabetic or numeric character.
May be quoted or unquoted where:
In unquoted elements
Spaces are not allowed.
The only special characters allowed are +,-,_
Cannot be the same as a GAMS reserved words (set, table, variable, parameter, etc.) are not allowed.
In quoted elements
Spaces are allowed.
Any special characters are allowed (including international ones if charset=1 option used).
Must have quotes that begin and end each element name.
Use either the symbol " or '  for the quotes.
GAMS reserved words are allowed in quotes.
Quoted and unquoted elements can be mixed.
Is case sensitive in subsequent references but case structure used in the first occurrence of the name will be the way it is printed out.
Will be referred to in quotes in assignments or equations if an individual element is to be addressed.

Examples:

Here the element names are in blue.  Note for ease of understanding, each element is on a separate line (namerules.gms)

 

Set   mshoes /tennis

 has+special-characters

 an_underscore

 3

 3number                /;

Set   shoes2 /"variable"

 "*starts_with_*"

 "has a space"

 'has "quotes" in it'

 'contains,a comma'        /;

Set   shoes3 /tennis

 "has spaces"                /;

 x("Tennis")=3;

y('an_underscore')=1;