SPSS: Data Editor: Define Variables

Defining your variables

You can define your variables by either double-clicking on the "var" at the top of the column or click in the column you want to define the variable for and then choose "Data" from the menu and select "Define Variable". Either way, a Define Variable window will appear.

We will create a variable called "sex" that will represent the gender of the respondent. It will be a classification variable with 1= "Male" and 2="Female".

Variable Name

The variable name is what you want to call the variable. Here are some rules you have to follow when naming variables.

Level of Measurement

There are four levels of measurement: Nominal, Ordinal, Interval, or Ratio. SPSS has combined these into three levels, Nominal, Ordinal, and Scale (Interval or Ratio).

Nominal or Ordinal data can be either string (alphanumeric) or numeric. Scale variables cannot contain strings (letters), only numbers.

Variable Type

Click on Type to change the data format.

All variables are assumed to be numeric by default.

For numeric, comma, and dot formats, you can enter any number of decimal places and the entire number is saved. The data editor will only display the number with the given number of decimal places. Since SPSS uses this information for the display of the data and not the storage, it is okay to leave nominal and ordinal data used as classification variables as the default 8.2.

Let me repeat that. For numeric data, you can leave it set at width=8 and decimals=2. This will save you time when entering numbers.

String values are padded on the right with spaces to fill the required width. If you specify a width of 8 or less, then a string can be used as categorical data. If you specify a width of more than 8 characters, then it becomes a long string and cannot be used as categorical data.

For date, dollar, or custom currency choices, you are given a scrollable list of formats to choose from.

When you are done defining the variable type, press the "Continue" button.

Define Labels

Variable names are limited to 8 characters, but the variable label may be up to 256 characters long. The descriptive labels are displayed in the output.

If the variable is categorical, then you can specify the values and their labels here.

Since 1 is going to represent males, enter a value of 1 and a value label of "Male" (without the quotes) and click on add. Then enter a value of 2 and a value label of "Female" and click on add.

Your screen should now look like this.

The format of the labels will depend on the variable type. If you define your type as Numeric8.2, then you will get 1.00="Male" as the entry. If you define your type as Numeric2.0, then you will get 1="Male". If you don't like the decimals, then change your type to have no decimal places.

Click "Continue" when all of the values are added.

Missing Values

There are two types of missing values in SPSS. There are system-missing values and user-missing values.

A system-missing value is used whenever a numeric cell is blank or contains a period. It is represented by a period. System-missing values are not used in calculations.

User-missing values can be used to indicate why data is missing. For example, you may wish to distinguish between a person that didn't respond and a question that wasn't applicable.

Typically, user-missing values are defined as all 9's like 9, 99, or 999 depending on the number of digits in a normal response. You can classify more than one value as missing, but make the missing values outside the range of what you would normally enter for that variable.

You should label your missing values in the previous step.

For our example, we'll only use the system-missing value. You don't need to define it as missing, so we have "No missing values", which is the default option.

Beware of missing values!

If you use values to represent user-missing data, but don't tell SPSS what values they are, then you will run into serious problems when analyzing the data.

For example, let's say that a question asked on a survey is the weight of the respondent. That would require three digits to code, so you decide to code a refusal to answer as 999. If you don't tell SPSS that 999 is a missing value, then it will use it as a normal data point and your weights will be heavily skewed to the right.

Click on "Continue" after defining your missing values.

Column Format

This controls the width and alignment of values in the data editor window. Changing the information here will not change the data, only the way it is displayed in the editor.

If you make the column too narrow, then asterisks "*" are displayed in the data editor window.

You may also change the column width by dragging the column borders between the variable names in the editor window.

Putting it all together

Here is how our example should look like after all of the data is entered.

Click "OK" to return to the data editor window.

Using Templates

When you have several variables with the same definitions, you can create a variable definition template and apply the template to the entire group of variables.

For example, let's say that you want to have the values 1="Yes" and 2="No" with 9="No Response". 9 is also considered a missing value.

Creating a Template

From the menu, choose "Data" and then "Templates".

Click "Define" in the dialog box.

Type the name of the template. In this case, we'll call it "Yes/No".

You have the ability to define a template in the same way you defined a variable earlier. Use the "Type", "Value Labels", "Missing Values", and "Column Format" to set it up the way you want it.

After you have modified the template to suit your needs, click "Add".

Click "Close" to return to the data editor window.

Modifying a Template

To modify an existing template, choose the template name from the pull down menu, click "Define", make the changes, and then click "Change".

Click "Close" to return to the data editor window.

Applying a Template

Select the variable by highlighting the variable name at the top of the column. You can select more than one variable by dragging across the variable names.

Then choose "Templates" from the "Data" menu. If you are only applying the template to a single variable, you can click the right mouse button and choose "templates".

Choose the Template to apply from the pull down menu and check all the attributes you wish to apply.

Then click "OK". The display is changed to represent the new values.