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
- increasing or decreasing the decimal places of standard numeric variables;
- displaying date, time and datetime values (consisting of numbers of seconds) as normal dates and times.
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).

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 Syntax Example 1
We'll now set two decimal places for monthly_income and rerun the exact same DESCRIPTIVES command with the syntax below.
formats monthly_income(f7.2).
*2. Rerun descriptives.
descriptives monthly_income.

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.

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
compute birthday_50 = datesum(date_of_birth,50,'years').
exe.
*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
formats education_type to experience_years(f2.1) monthly_income(dollar6) birthday_50(datetime20).
THIS TUTORIAL HAS 4 COMMENTS:
By Diarmuid Hayes on February 26th, 2017
Hi Ruben,
Thanks for the post. I had never noticed the difference between variable type and formats before.
Regarding assigning variable types: if you have a variable consisting of binomial/categorical data, entered as numbers which are codes for category names (such as "living/dead" assigned 1 or 0 respectively), would you recommend assigning these as numerical or string types?
Thanks
Diarmuid
By Ruben Geert van den Berg on February 26th, 2017
In my opinion, string variables are only the way to go for nominal variables that contain few or no ties. For example, first name, ZIP code, home address, email address and so on.
By Georgi Stoyanov on April 25th, 2017
Thanks, great tutorials!
By Ruben Geert van den Berg on April 25th, 2017
Hi Georgi, thanks for the compliment!
P.s. are you Bulgarian? I'm really hoping to visit Rila national park this summer and perhaps do some business in Sofia.