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 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.
Index of Sample Python Scripts
Python scripts are broadly classified by purposes as follows:
- Self adjusting code
- Age-adjusted prevalence using SPSS Complex Sample
- XML files
- Data Import and Export
- Working with Output Doc
To err is human but… some people are more human than others.
Sample Python scripts
Self adjusting code
- Command depends on existence of a var.sps
- Pass an argument to python.SPS
- Pass an argument to Python with DATAFILE ATTRIBUTE.SPS
- 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.)
- 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.
- 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.
Data Import and Export
- 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)