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.

Conference stuff

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

And these materials were prepared earlier, before Python-era in SPSS, for SPSS Directions conference in Las Vegas, October 2004. See 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. Data Import and Export
  5. Working with Output Doc

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. Pass an argument to Python with DATAFILE ATTRIBUTE.SPS
  4. 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.

Data Import and Export

  1. Python savReaderWriter package (link to Python package repository with Albert-Jan Roskam's development for reading and writing SPSS files without SPSS Statistics application installed)

Working with Output Doc

  1. Replace Outline Page Title By Title Content.sps