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
- For string variables, width refers to how many characters a value can hold. An exception are multibyte characters as explained in SPSS Unicode Mode.
- Somewhat confusingly, “width” is not the width of a variable’s column as displayed on screen, which is referred to as columns.
- For string variables, width should be increased when new values are desired that are longer than the current width. This is demonstrated by the syntax example below.
- For numeric variables, “width” refers to how many digits should be displayed. However, SPSS will often override the specified width is it’s insufficient. If not,
FORMATScan be used for increasing it.
SPSS Formats and Alter Type Syntax Examples
(The test data used by the syntax below are found here.)
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
- Decimal places can be changed by the
FORMATScommand. Just note that the first number refers to the width of the entire variable (including decimals) so the second number (decimals) should always be smaller. - Also, keep in mind that the actual data values will not change because of using
FORMATS. They are merely displayed differently.
SPSS Formats Syntax Example
(The test data used by the syntax below are found here.)
formats income(f5.2).
