When working with SPSS, specifying missing values correctly is often an essential step in analyzing data. This tutorial demonstrates how to set missing values the right way.
Setting Missing Values in SPSS
- Perhaps unsurprisingly, missing values can be specified with the
MISSING VALUES
command. - A thing to note, however, is that missing values can be specified for multiple variables at once.
- Second, missing values may be specified as a range. If a range is used, a single discrete missing value can be added to it.
- The syntax example below gives some examples of this.
SPSS Missing Values Syntax Examples
(The test data used by the syntax below are found here.)
*1. Specifying 4 and 5 as missing values for "married".
missing values married(4,5).
*2. Specify a range (1,000,000 and upwards) as missing values for "income".
missing values income (1000000 thru hi).
*3. Specify 2 as missing value for variables q1 through q3.
missing values q1 to q3 (2).
missing values married(4,5).
*2. Specify a range (1,000,000 and upwards) as missing values for "income".
missing values income (1000000 thru hi).
*3. Specify 2 as missing value for variables q1 through q3.
missing values q1 to q3 (2).
Changing Columns in SPSS
- Columns refers to how wide a variable column is displayed on screen. It can be set by the
VARIABLE WIDTH
command. - This may be confusing since this does not refer to the "width" (length) of a variable as explained under variable width.
- Although setting columns doesn't affect your actual data, it's of minor importance. For the sake of completeness, the syntax example below demonstrates the command.
SPSS Variable Width Syntax Example
(The test data used by the syntax below are found here.)
*Set columns = 50 for q1 through q3..
variable width q1 to q3 (50).
variable width q1 to q3 (50).
Changing Variable Alignment in SPSS
- Variable alignment refers to how data values are aligned within their columns. The options are "left", "centered" or "right".
- As in MS Excel, the default settings are left for string variables and right for numeric variables.
- These can be overridden by the
VARIABLE ALIGNMENT
command as demonstrated below.
SPSS Variable Align Syntax Example
(The test data used by the syntax below are found here.)
*Set Variable Alignment = center for q1 through q3.
variable alignment q1 to q3 (center).
variable alignment q1 to q3 (center).
Changing Measurement Levels in SPSS
- On a personal note, we feel the Measure property for setting measurement levels is rather useless. This is something that users - not software - should be aware of and take into account when analyzing data.
- Regretfully, some commands (most notably
CTABLES
) are actually affected by the measurement levels as specified by the user. - In this case, the
VARIABLE LEVEL
command can be used for setting them to nominal, ordinal or scale (for metric variables).
SPSS Variable Level Syntax Example
(The test data used by the syntax below are found here.)
*Set measurement level to scale for "birthday", ordinal for "married" and nominal for q1 through q3.
variable level birthday(scale) married(ordinal) q1 to q3 (nominal).
variable level birthday(scale) married(ordinal) q1 to q3 (nominal).
Changing Roles in SPSS
- Just as with Measure, we feel the "Role" property is rather useless and had perhaps better be removed from SPSS.
- For the sake of completeness, it can be modified as demonstrated below.
SPSS Variable Role Syntax Example
(The test data used by the syntax below are found here.)
*Set role to input for "married", target for "income" and both for "q1" through "q3".
variable role
/input married
/target income
/both q1 to q3.
variable role
/input married
/target income
/both q1 to q3.
THIS TUTORIAL HAS 13 COMMENTS:
By Ruben Geert van den Berg on March 3rd, 2016
Hi Katherine! Good question! The syntax example below shows how to do it.
Keep in mind that you can specify multiple variables at once in the
MISSING VALUES
command.data list free/id.
begin data
1 2 3 4 5
end data.
*Set 5 as missing value.
missing values id (5).
frequencies id.
*Specify no values whatsoever as missing.
missing values id ().
frequencies id.
By Raina on June 6th, 2016
Hi Ruben!
Say I have a file that lists clients and notes that have been written about those clients by a practitioner. Each note is a different length and different text. I know that I can widen the viewing field in the Data Editor in SPSS using the "variable width" command. Is there a way to also wrap the text in Data Editor so that I can see the whole comment without having to click on it? As always, thanks for your help!
By Ruben Geert van den Berg on June 7th, 2016
Hi Raina!
I don't think it's possible in SPSS. Perhaps save the file as MS Excel?
By Raina on June 8th, 2016
Well, I was trying to wrap the text in SPSS so that when I export many files to excel, they would all be automatically wrapped and I wouldn't have to go through and manually wrap the text in two fields in 21 separate files.
The reason I have the 21 files is from your awesome python code that lets me separate and export to excel based upon a grouping variable. I want to keep that part! :)
By Ruben Geert van den Berg on June 9th, 2016
Hi Raina!
Are you sure you really want 21 separate files when the data structure allows for everything in one single file? That seems like a serious violation of database normalization principles.
I don't have a solution for this. Perhaps you could try and set the text wrap as the Excel default? I'm not sure, I don't know a lot about Excel.