Variable Names

Variable names are stored in the dictionary of the data file. Observe the following rules when establishing variable names or referring to variables by their names on commands:

  • Each variable name must be unique; duplication is not allowed.
  • Variable names can be up to 64 bytes long, and the first character must be a letter or one of the characters @, #, or $. Subsequent characters can be any combination of letters, numbers, nonpunctuation characters, and a period (.). In code page mode, sixty-four bytes typically means 64 characters in single-byte languages (for example, English, French, German, Spanish, Italian, Hebrew, Russian, Greek, Arabic, and Thai) and 32 characters in double-byte languages (for example, Japanese, Chinese, and Korean). Many string characters that only take one byte in code page mode take two or more bytes in Unicode mode. For example, é is one byte in code page format but is two bytes in Unicode format; so résumé is six bytes in a code page file and eight bytes in Unicode mode.
    Note: Letters include any nonpunctuation characters used in writing ordinary words in the languages supported in the platform's character set.
  • Variable names cannot contain spaces.
  • A # character in the first position of a variable name defines a scratch variable. You can only create scratch variables with command syntax. You cannot specify a # as the first character of a variable in dialogs that create new variables.
  • A $ sign in the first position indicates that the variable is a system variable. The $ sign is not allowed as the initial character of a user-defined variable.
  • The period, the underscore, and the characters $, #, and @ can be used within variable names. For example, A._$@#1 is a valid variable name.
  • Variable names cannot begin or end with a period. Names that begin with a period are invalid; names the end with a period may be interpreted as a command terminator. You cannot create variables that begin or end with a period in dialogs that create new variables.
  • Variable names ending in underscores should be avoided, since such names may conflict with names of variables automatically created by commands and procedures.
  • Reserved keywords cannot be used as variable names. Reserved keywords are ALL, AND, BY, EQ, GE, GT, LE, LT, NE, NOT, OR, TO, and WITH.
  • Variable names can be defined with any mixture of uppercase and lowercase characters, and case is preserved for display purposes.
  • When long variable names need to wrap onto multiple lines in output, lines are broken at underscores, periods, and points where content changes from lower case to upper case.