SPSS tutorials

BASICS DATA ANALYSIS T-TEST ANOVA CHI-SQUARE TEST

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

Previous tutorial: Changing Variable Properties 3 – Type

Next tutorial: SPSS – Set Missing Values with Syntax

Let me know what you think!

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

This tutorial has 2 comments