SPSS tutorials website header logo SPSS TUTORIALS VIDEO COURSE BASICS ANOVA REGRESSION FACTOR

SPSS Dictionary

It's not informative that "a respondent has 0 on v1" unless you know what v1 and 0 refer to. Such information - what the data actually represent - is collectively know as the dictionary.

This tutorial merely explains what the SPSS dictionary is. For learning how to modify it properly (that is, by syntax), see Changing Variable Properties 1 - Introduction.

SPSS Dictionary - What is it?

SPSS Dictionary Commands

SPSS Dictionary - Complete Overview

Note: we tried to sort these properties from most to least important. "Optional" indicates whether a property can (technically) be absent.

NameApplies toFunctionImportanceOptional
variable nameVariableVariable identifier.HighNo
LabelVariableNormal language description of the meaning of variables.HighYes
Value LabelsValueNormal language description of the meaning of values.HighYes
User Missing ValuesValueTells SPSS which values to ignore in calculations.HighYes
TypeVariableTells SPSS how to store values internally.HighNo
FormatVariableTells SPSS how to display numeric values.HighNo
DocumentData fileLong data file description.LowYes
WidthVariableMaximum number of characters that values may consist of.LowNo
ColumnsVariableVariable's column width (as displayed on screen).LowNo
Variable AttributeVariableDescriptive tags for variables.LowYes
Datafile attributeData fileData file description using arrays.LowYes
File labelData fileShort data file description.LowYes
AlignVariableAlignment of data values (on screen).LowNo
MeasureVariableMeasurement level nominal, ordinal or scale (= metric).LowNo
RoleVariableThe variable's supposed relation to other variables.LowNo

SPSS – How to Set Missing Values from Syntax?

Introduction & Practice Data File

When working with SPSS, specifying missing values correctly is often an essential step in analyzing data. This tutorial demonstrates how to set missing values the right way.

Setting Missing Values in SPSS

SPSS Missing Values Syntax Examples

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

*1. Specifying 4 and 5 as missing values for "married".

missing values married(4,5).

*2. Specify a range (1,000,000 and upwards) as missing values for "income".

missing values income (1000000 thru hi).

*3. Specify 2 as missing value for variables q1 through q3.

missing values q1 to q3 (2).

Changing Columns in SPSS

SPSS Variable Width Syntax Example

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

*Set columns = 50 for q1 through q3..

variable width q1 to q3 (50).

Changing Variable Alignment in SPSS

SPSS Variable Align Syntax Example

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

*Set Variable Alignment = center for q1 through q3.

variable alignment q1 to q3 (center).

Changing Measurement Levels in SPSS

SPSS Variable Level Syntax Example

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

*Set measurement level to scale for "birthday", ordinal for "married" and nominal for q1 through q3.

variable level birthday(scale) married(ordinal) q1 to q3 (nominal).

Changing Roles in SPSS

SPSS Variable Role Syntax Example

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

*Set role to input for "married", target for "income" and both for "q1" through "q3".

variable role
/input married
/target income
/both q1 to q3.

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

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

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".

Changing Variable Properties 4 – Width and Decimals

Changing a variable's width is rarely necessary. Nevertheless, it's good to know how when it's needed and how it's done.

Changing Variable Width in SPSS

SPSS Formats and Alter Type Syntax Examples

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

*1. Width for "income" increases from 5 to 6 after running the line below.

formats income(f6.0).

*2. "Stefano" (7 letters) is too long for "name" (6 letters). We'll therefore increase its width to 7 characters.

alter type name(a7).

*3. Now we can change "Stefan" to "Stefano".

if name eq 'Stefan' name = 'Stefano'.
execute.

Changing Decimal Places in SPSS

SPSS Formats Syntax Example

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

*Note how running the line below displays two decimals for "income" under "Data View".

formats income(f5.2).

Changing Variable Properties 3 – Type

SPSS offers several ways to change a variable's type. This tutorial will walk you through some examples.

SPSS Variable Type - Why Change it in the First Place?

Changing Variable Type in SPSS

SPSS Alter Type Syntax Examples

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

*1. Convert "birthday" to string.

alter type birthday(a10).

*2. Convert back to numeric variable with date format.

alter type birthday(edate10).

SPSS String and Numeric Functions

SPSS String and Numeric Syntax Examples

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

*1. String command for declaring new string variable.

string str_q1(a1).

*2. Fill new string variable with values.

compute str_q1 = string(q1,f1)./* String function.
exe.

*3. Convert new string variable back into a (new) numeric variable.

compute num_q1 = numeric(str_q1,f1).
exe.

*4. Remove both new variables after exercise.

delete variables str_q1 num_q1.

SPSS Autorecode Command and Valuelabels Function

SPSS Autorecode and Valuelabels Syntax Examples

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

*1. Convert string to (new) numeric variable with autorecode command.

autorecode name
/into num_name.

*2. Declare new string variable with string command.

string str_name(a10).

*3. Fill string variable with value labels of (numeric) variable.

compute str_name = valuelabels(num_name).
exe.

*4. Delete both variables at end of exercise.

delete variables num_name to str_name.

Changing Variable Properties 2 – Names

The right way for changing variable names in SPSS is using RENAME VARIABLES. Changing variable names manually in variable view is a bad idea because you can't keep track of what you did. This tutorial shows a better alternative.

Changing Variable Names in SPSS

SPSS Rename Variables Syntax Examples

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

*1. Basic variable renaming.

rename variables name = first_name.
rename variables married= marital_status.

*2. Rename both variables back to their original names (undo previous 2 commands).

rename variables (first_name marital_status = name married).

Changing Variable Properties 1 – Introduction

A great way to start working from syntax is using "Paste" instead of "Ok". However, there's no "Paste" option for modifying most variable properties. This tutorial shows how handle that properly.

Changing Variable Properties

Creating Test Data

Running the syntax below will create some test data. We'll use it in the following tutorials to demonstrate how to modify each of the variable properties individually.
*Create some test data for modifying variable properties.

data list free/name(a6) birthday(edate10) married(f1) income(f5.0) q1 q2 q3.
begin data
Chris 15/4/1979 1 2880.5 0 1 0
Stefan 10/1/1978 0 4812.45 1 1 1
Anneke 31/3/1947 2 3438.12 1 2 2
end data.

Click on of the Properties in the Screenshot Below

Overview Changing Variable Properties

  1. Changing Variable Names in SPSS
  2. Changing Variable Type in SPSS
  3. Changing Variable Width in SPSS
  4. Changing Variable Decimals in SPSS
  5. Changing Variable Labels in SPSS
  6. Changing Value Labels in SPSS
  7. Setting Missing Values in SPSS
  8. Changing Columns in SPSS
  9. Changing Variable Alignment in SPSS
  10. Changing Variable Measure in SPSS
  11. Changing Variable Role in SPSS