Unit 13 · Dissertation toolkit

SPSS syntax for beginners

Use the Paste button and the SPSS Syntax Editor to write, run, comment and save .sps files so your analysis is reproducible.

Free tutorialPro practiceAbout 5 minutes7 practice questions

Quick answer: How do you use SPSS syntax?

  1. In any dialog, click Paste instead of OK to write the syntax.
  2. Every command ends with a full stop.
  3. Select the lines and choose Run › Selection (Ctrl+R).
  4. Save the file as .sps next to your data.

Last updated November 2026 · Not sure this is the right test? Try the Which statistical test? tool.

Why use SPSS syntax?

Syntax is SPSS’s command language. Every dialog writes syntax behind the scenes, and the Paste button shows it to you. Saving your syntax gives a complete, rerunnable record of everything you did to your data.

When to use it

  • Any project you might need to rerun, such as a dissertation after correcting data.
  • Repetitive tasks, such as running the same analysis on many variables.
  • Sharing your exact analysis with a supervisor.

How it works

Commands start at the left margin and end with a full stop. Subcommands start with a slash. Comments start with an asterisk and also end with a full stop. Highlight lines and choose Run › Selection to run them. Pasting from dialogs means you rarely need to type syntax from scratch.

Worked example

A syntax file that recodes items, computes scale means and runs every analysis lets you rebuild your entire results section in seconds if one participant’s data is corrected.

Key terms

Paste
Writes a dialog’s settings as syntax instead of running it.
.sps
Syntax file.
.sav
Data file.
.spv
Output file.

Common mistakes

  • Forgetting full stops.
  • Running only part of a file and assuming earlier transformations ran.

How to do it in SPSS

The Syntax Editor

Every dialog has a Paste button that writes the matching commands into a Syntax Editor. Saving that file gives you a complete, rerunnable record of your analysis.

Syntax1 – IBM SPSS Statistics Syntax Editor
FileEditViewDataTransformAnalyzeGraphsUtilitiesRun4ToolsWindowHelp
* Descriptives for exam score.1
DESCRIPTIVES VARIABLES=score age2
  /STATISTICS=MEAN STDDEV MIN MAX.3

T-TEST GROUPS=teaching(1 2)
  /VARIABLES=score.
  1. 1
    CommentLines starting with * are notes to yourself. They must end with a full stop too.
  2. 2
    Command and subcommandsEach command starts at the left edge. Subcommands start with / and can go on new lines.
  3. 3
    Full stopEvery command ends with a full stop. Missing one is the most common syntax error.
  4. 4
    RunSelect the lines you want, then Run › Selection (Ctrl+R), or press the green triangle.

Save syntax as a .sps file next to your data (.sav). Your output saves separately as .spv.

The SPSS syntax

Prefer typing to clicking? Open File › New › Syntax, paste this in, select it and choose Run › Selection. Every dialog's Paste button writes the same kind of code.

* Descriptives for exam score.
DESCRIPTIVES VARIABLES=score age
  /STATISTICS=MEAN STDDEV MIN MAX.

T-TEST GROUPS=teaching(1 2)
  /VARIABLES=score.

Practice data

Download the file used in this lesson and run it yourself in SPSS: you should get the same results as the screens above.

  • online.savExam scores for online and in-person students (N = 100)

Now practise it interactively →

Reading is only half of it. Tap through the real SPSS menus, read the output and pick the right write-up in 7 quick questions, with instant feedback on every answer.

Practice for this lesson is part of Pro, with every unit, unlimited hearts and saved progress.

More in Dissertation toolkit