KEY Subcommand (KEYED DATA LIST command)

KEY specifies the variable whose value will be used as the key. This variable must already exist as the result of a prior DATA LIST, KEYED DATA LIST, GET, or transformation command.

  • KEY is required. Its only specification is a single variable. The variable can be a permanent variable or a scratch variable.
  • For direct-access files, the key variable must be numeric, and its value must be between 1 and the number of records in the file.
  • For keyed files, the key variable must be string. If the keys are numbers, such as social security numbers, the STRING function can be used to convert the numbers to strings. For example, the following might be required to get the value of a numeric key into exactly the same format as used on the keyed file:
COMPUTE #KEY=STRING(123,IB4).