SPSS FORMATS – Set Display Format for Variables

SPSS FORMATS sets formats -decimal places, dates, percent signs and more- for numeric variables. Setting variable formats in SPSS does not change your actual data values. However, formats determine how your data are displayed -in the data viewer as well as the output window. Two main uses of FORMATS are

So let's try it and see how it works. All examples in this tutorial use employees.sav.

Setting Decimal Places

One of the main uses of FORMATS is setting decimal places for standard numeric variables by specifying their desired f formats. For example, we don't see any decimal places for monthly_income in data view except for the formula bar when we select a value (see screenshot).

SPSS Formats Command F4

Its current format, F4, does not only hide all decimals in data view but affects some of the output as well. We can see this by running the following syntax: descriptives monthly_income.

SPSS FORMATS Command in Output 1

SPSS FORMATS Syntax Example 1

We'll now set two decimal places for monthly_income and rerun the exact same DESCRIPTIVES command with the syntax below.

*1. Specify two decimal places with FORMATS command.

formats monthly_income(f7.2).

*2. Rerun descriptives.

descriptives monthly_income.
SPSS FORMATS Command in Output 1

Note how all decimal places in the output table have increased by 2 by changing the variable's format. Apart from that, the F7.2 format also displays 2 decimal places in data view now (see next screenshot). Keep in mind that the actual values don't change in any way by running FORMATS.

SPSS Formats Command F7.2

Setting Date, Time and Datetime Formats

When new date variables, time variables and datetime variables are created, they may initially hold huge numbers that don't look like dates and time at all. These huge numbers are their actual values in numbers of seconds. These are only shown as normal dates and times after setting their formats appropriately. The syntax below demonstrates how to do so.

SPSS FORMATS Syntax Example 2

*1. Compute date of 50th. birthday for respondents.

compute birthday_50 = datesum(date_of_birth,50,'years').

*2. Show numbers of seconds as normal date values.

formats birthday_50(date11).

The reason why this is usually necessary is that SPSS date, time and datetime variables are numeric variables. In SPSS, new numeric variables initially have an f format, usually F8.2. Those who really want to know can confirm this by running show format.

Multiple Variables

Formats can be set for multiple variables at once; after FORMATS, specify one or more variable names followed by their format. If desired, the command may continue with more variable names, again followed by their format. The syntax below gives an example.

SPSS FORMATS Syntax Example 3

*Set different formats for different sets of variables at once.

formats education_type to experience_years(f2.1) monthly_income(dollar6) birthday_50(datetime20).

Tell us what you think!

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