SPSS – Set Variable Labels with Syntax

Managing variable and value labels without syntax is way more work than necessary. This tutorial explains how to do this more efficiently.

Changing Variable Labels in SPSS

  • As with other parts of the dictionary, there’s no “Paste” option for modifying variable labels.
  • Be aware that manual modifications – apart from being time consuming – are not recorded in the journal file. The way to go here is using syntax.
  • Changing or adding variable labels is straightforward using the VARIABLE LABELS command.
  • Although not always necessary, it is recommended to always use quotes around the label text.
  • If more than one variable is labelled in a single command, use slashes (/) to separate specifications.

SPSS Variable Labels Syntax Examples

(The test data used by the syntax below are found here.)

*1. Modify (or add) a single variable label.

variable labels name ‘First name of respondent’.*2. Modify (or add) two variable labels in a single command.

variable labels birthday ‘Birthday of respondent’/married ‘Marital status of respondent’.

Changing Value Labels in SPSS

  • The VALUE LABELS command should be used carefully since it will first erase all value labels for a variable and then apply whatever you specify. This often made mistake is demonstrated in the syntax below.
  • Often, ADD VALUE LABELS is a better alternative for changing or adding value labels.
  • Note that both commands can be applied to multiple variables simultaneously. This may save a lot of time when combined with TO and ALL keywords.
  • Note that the value labels themselves should be quoted. If there’s a single quote in a label, you need to escape it by doubling it. Alternatively, double quotes can be used around a labels containing single quotes.

SPSS Value Labels Syntax Examples

(The test data used by the syntax below are found here.)

*1. Apply single value label. Note how it appears under Variable View.

value labels married 1 ‘Never married’.*2. Wrong way for adding/changing value labels. This removes the value label we added in the previous command.

value labels married 2 ‘Married’.*3. Right way: use ADD VALUE LABELS instead of VALUE LABELS.

add value labels married 1’Never married’ 3’Other’ 4 ‘Don”t want to tell’ 5 ‘Question skipped’.*4. Alternative: apply all value labels in a single command.

value labels q1 q2 q3 0 ‘No’ 1 ‘Yes’ 2 “Don’t know/not applicable”.