Chapter 16

Computing Variables with Syntax

IN THIS CHAPTER

Bullet Writing Syntax that performs a series of steps

Bullet Using DO IF … END IF

In Chapter 15, you were introduced to the Syntax window and computed a few variables. In this chapter, you work with more complex examples. You revisit some of the functions you encountered in Chapter 5, when you created variables by using the Compute Variable dialog, but this time you create the variables by writing code. Once you get the hang of it, you can compute variables faster in the Syntax window than by using Paste from the dialogs.

Remember If you get stuck looking at an empty Syntax window, simply go back and use the Paste button in the dialogs for help. Then after you've used the commands for a while, switch to modifying.

Calculating New Variable with Syntax

In this section, you repeat the difference calculation from Chapter 5, but you type the formula in the Syntax window rather than use the dialogs:

  1. Choose File  ⇒    Open  ⇒    Data and load the GSS2018.sav file.

    Download the file from the book’s companion website at www.dummies.com/go/spssstatisticsworkbookfd.

  2. Choose File  ⇒    New  ⇒    Syntax.
  3. Type COMPUTE.

    Do not type a period until the entire ...

Get SPSS Statistics Workbook For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.