Home FAQ Syntax Macros Scripts Python Tips Links

IBM SPSS Statistics-Python Integration

No, Python is not a snake! Starting with version 14, it is possible to run Python Scripts synchronously with SPSS syntax files. This opens up many exciting opportunities.

Python is an Open Source interpreted, interactive, object-oriented language (see I bought and recommend Beginning Python, From Novice to Professional by Magnus Lie Hetland. The book is published by Apress and is available from Amazon.

In May 2007, I made a presentation in Prague on Python and GGRAPH, the related programs are in this page.

Index of Sample Python Scripts

Python scripts are broadly classified by purposes as follows:

  1. Self adjusting code
  2. Age-adjusted prevalence using SPSS Complex Sample
  3. XML files
  4. Temporary

Note: Files with a new.gif (111 bytes) at the end were added or modified less than 30 days ago.

To err is human but ... some people are more human than others.

Sample Python scripts

Self adjusting code

  1. Command depends on existence of a var.sps
  2. Pass an argument to python.SPS
  3. Run macro only if there are cases.SPS (very useful to avoid runtime errors when dataset becomes empty as a result of SELECT IF or similar commands.)

Age-adjusted prevalence

  1. This tool greatly simplifies the writing of syntax to determine age-adjusted prevalence using SPSS Complex Sample Survey. Instructions, datasets, and sample results are all included in the following zip file:
    The instructions acknowledges the contributions of those who gave Juan Albertorio, Art Kendall and myself a hand with the preparation of this python module and related documents.

XML files

  1. This module reads and converts sample.xml into a sav file. You need to change the extension from .txt to .py once you have downloaded the module.


  1. Hide cell when less than n persons.SPS
  2. (Note: This file does not use Python, it will be relocated later)