Scripting with the Python Programming Language

IBM® SPSS® Statistics provides two separate interfaces for programming with the Python language on Windows, Linux, Mac OS, and for IBM SPSS Statistics Server. Use of these interfaces requires the IBM SPSS Statistics - Integration Plug-in for Python, which is installed by default with your IBM SPSS Statistics product. For help getting started with the Python programming language, see the Python tutorial, available at http://docs.python.org/tut/tut.html .

Python Scripts

Python scripts make use of the interface exposed by the Python SpssClient module. They operate on user interface and output objects and can also run command syntax. For instance, you would use a Python script to customize a pivot table.

  • Python scripts are run from Utilities>Run Script, from the Python editor launched from IBM SPSS Statistics (accessed from File>Open>Script), or from an external Python process, such as a Python IDE or the Python interpreter.
  • Python scripts can be run as autoscripts.
  • Python scripts run on the machine where the IBM SPSS Statistics client is running.

Complete documentation of the IBM SPSS Statistics classes and methods available for Python scripts can be found in the Scripting Guide for IBM SPSS Statistics, available under Integration Plug-in for Python in the Help system.

Python Programs

Python programs make use of the interface exposed by the Python spss module. They operate on the IBM SPSS Statistics processor and are used to control the flow of a command syntax job, read from and write to the active dataset, create new datasets, and create custom procedures that generate their own pivot table output.

  • Python programs are run from command syntax within BEGIN PROGRAM-END PROGRAM blocks, or from an external Python process, such as a Python IDE or the Python interpreter.
  • Python programs cannot be run as autoscripts.
  • In distributed analysis mode (available with IBM SPSS Statistics Server), Python programs execute on the computer where IBM SPSS Statistics Server is running.

More information about Python programs, including complete documentation of the IBM SPSS Statistics functions and classes available for them, can be found in the documentation for the Python Integration Package for IBM SPSS Statistics, available under Integration Plug-in for Python in the Help system.