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 www.python.org). 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. Temporary

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: ageAdjusted.zip
    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  ReadSampleXMLfile.py 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.

Temporary

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