By Ruben Geert van den Berg on March 20, 2016 under Other Essential Basics.

SPSS Variable Types and Formats Tutorial

Understanding SPSS variable types and formats allows you to get things done fast and reliably. Getting a grip on types and formats is not hard if you ignore the very confusing information under variable view. This tutorial takes away the confusion and puts you back in control.
We encourage you to follow along with this tutorial by downloading and opening computer_parts.

SPSS Variable Types and Formats

SPSS Variable Types

SPSS has two variable types: string and numeric. Numeric variables may contain only numbers. String variables may contain letters, numbers and other characters. The distinction between numeric and string variables is important because the variable type dictates what you can or cannot do with a variable.

There are no other variable types in SPSS than string and numeric. However, numeric variables have several different formats that are often confused with variable types. We'll see in a minute how SPSS variable view puts many users on the wrong track here.

SPSS Variable Type versus Formats

Determining SPSS Variable Types

Before doing anything whatsoever with a variable, we always want to know whether it's a string or numeric variable. Don't rely on a visual inspection of your data view for determining variable types; it may be hard, sometimes impossible to see the difference between the two variable types. Instead, inspect your variable view and use the following rule:

SPSS Variable Types and Formats

SPSS suggests that “Date” and “Dollar” are variable types as well. However, these are formats, not types. The way they are shown here among the actual variable types (string and numeric) is one of SPSS’ most confusing features.

SPSS Variable Formats - Introduction

Let's now have a look at the data under data view as shown the screenshot below. We'll briefly describe the kinds of variables we see.

SPSS Variable Types and Formats

The first variable holds words;
The second variable holds numbers with two decimal places;
The third variable holds dates;
The fourth variable holds times;
The fifth variable holds dates and times;
The sixth variable holds percentages;
The seventh variable holds numbers of dollars with two decimal places.

Regarding these data, we concluded earlier that is a string variable and variables through are numeric. Remember that numeric variables can contain only numbers. However, SPSS can display these numbers in very different ways. At this point we see that numeric values have two components:

These different ways of displaying and treating the actual values are referred to as variable formats.

Determining SPSS Variable Formats

As we saw earlier, “Type” under variable view shows a confusing mixture of variable types and formats. Unfortunately, it doesn't allow us to determine the actual formats. However, the following line of syntax does the trick here: display dictionary. After running it, we see one or more tables with dictionary information in the Output Viewer window as shown by the screenshot below.

SPSS Variable Formats

SPSS distinguishes print and write formats but we don't bother about this distinction. SPSS variable formats consist of two parts. One or more letters indicate the format family. Most of them speak to themselves, except for the first two variables:

Formats end with numbers, indicating the number of characters to be shown.Strictly, in the case of string variables the number indicates the maximum number of bytes that each value may consist of. For more on this, see Unicode mode If a period is present, the number after the period indicates the number of decimal places to be displayed.

SPSS Common Variable Formats

The table below disambiguates variable types, format families and formats for the data we've been studying so far.

Variable TypeFormat familyFormat (example)Shown as
StringAA10Word.
NumericFF5.219.99
NumericDATEDATE1108-jan-2013
NumericTIMETIME816:56:10
NumericDATETIMEDATETIME208-Jan-2013 18:34:05
NumericPCTPCT6.221.99%
NumericDOLLARDOLLAR6.2$18.83

Related Tutorials

SPSS ALTER TYPE Command

SPSS ALTER TYPE command is mainly used for converting string variables to numeric variables. However, it has other interesting applications as well. This tutorial quickly walks you through those, pointing out some pitfalls, tips and tricks along the way. Read more

SPSS FORMATS Command

SPSS FORMATS command is mainly used for setting decimal places for numeric variables. FORMATS also displays SPSS date and time values properly. This tutorial will briefly demonstrate both uses. Read more

Comment on this Tutorial

*Required field. Your comment will show up after approval from a moderator.

This Tutorial has 19 Comments