Value Labels for String Variables (ADD VALUE LABELS command)

  • For string variables, the values and the labels must be enclosed in single or double quotes.
  • If a specified value is longer than the defined width of the variable, the program displays a warning and truncates the value. The added label will be associated with the truncated value.
  • If a specified value is shorter than the defined width of the variable, the program adds blanks to right-pad the value without warning. The added label will be associated with the padded value.
  • If a single set of labels is to be assigned to a list of string variables, the variables must have the same defined width (for example, A8).

Example

ADD VALUE LABELS  STATE 'TEX' 'TEXAS' 'TEN' 'TENNESSEE'
                        'MIN' 'MINNESOTA'. 
  • ADD VALUE LABELS assigns labels to three values of the variable STATE. Each value and each label is specified in quotes.
  • Assuming that the variable STATE is defined as three characters wide, the labels TEXAS, TENNESSEE, and MINNESOTA will be appropriately associated with the values TEX, TEN, and MIN. However, if STATE was defined as two characters wide, the program would truncate the specified values to two characters and would not be able to associate the labels correctly. Both TEX and TEN would be truncated to TE and would first be assigned the label TEXAS, which would then be changed to TENNESSEE by the second specification.

Example

ADD VALUE LABELS STATE REGION "U" "UNKNOWN".
  • The label UNKNOWN is assigned to the value U for both STATE and REGION.
  • STATE and REGION must have the same defined width. If they do not, a separate specification must be made for each, as in the following:
ADD VALUE LABELS STATE "U" "UNKNOWN" / REGION "U" "UNKNOWN".