Docsity

Calculating New Variables and Using IF Statements in SPSS, Slides of Economic statistics

Partial preview of the text

Download Calculating New Variables and Using IF Statements in SPSS and more Slides Economic statistics in PDF only on Docsity!

Calculating derived variables

Objectives

At the end of this session you will

  • be able to create a new variable using the

menu system.

  • be able to use the “IF” command to apply

different formula to a variable depending on

its values

Calculating new variables using

syntax When you clicked on PASTE the following commands should have appeared on the syntax window

COMPUTE diff = income - expend. Execute.

Notice:

  1. You tell SPSS what you want to do (compute)
  2. You order SPSS to do it! (execute).
  3. Both commands finish with a dot.

Now go back to the data window and delete the new variable Return to the syntax window and run the first command

Calculating new variables using

  • What happened? syntax
  • What happens when we run the second

command?

  • Write your conclusions

Using IF statements from the menu

On the compute variable dialog box:

  • click on IF,
  • select “Include if case satisfies condition”
  • write the condition,
  • and click “Continue”.

When you finish click PASTE

Using IF statements in the syntax

window The result is

IF (diff < 0 ) deficit = -.

EXECUTE.

Lets add the other conditions

IF (diff < 0 ) deficit = -.

IF (diff = 0 ) deficit = 0.

IF (diff > 0 ) deficit = 1.

EXECUTE.

Missing values in SPSS

For example, in the data set “ind data.sav”, children

would not be expected to have income. So most

individuals under 15 have a system missing value for

s1bq01 (Q01 Did..do any work during last month?).

Two overall types: System missing : shown as a dot on your data table User defined missing : certain values can be declared as missing values.

Missing values in SPSS

So let’s change the value of s1bq01 to 3 if the respondent did not do any work last month and the individual is younger than 15 years old.

if ( age < 15 and sysmis(s1bq01)) s1bq01 = 3. execute.

Declaring a user missing value in

SPSS

Using the syntax Using the variable view window

Missing value s1bq01 (3).

SPSS and missing values

  • SPSS treats missing values differently depending on what you are doing. Sometimes: - The data or full case is omitted, - The data are included but when used with non-missing values the result is a missing value - SPSS recognises them and manages them sensibly. Whatever you do, check how SPSS is treating your missing values and act accordingly.