Overview (BEGIN PROGRAM command)

BEGIN PROGRAM-END PROGRAM provides the ability to integrate the capabilities of external programming languages with IBM® SPSS® Statistics. One of the major benefits of these program blocks is the ability to add jobwise flow control to the command stream. Outside of program blocks, IBM SPSS Statistics can execute casewise conditional actions, based on criteria that evaluate each case, but jobwise flow control, such as running different procedures for different variables based on data type or level of measurement or determining which procedure to run next based on the results of the last procedure is much more difficult. Program blocks make jobwise flow control much easier to accomplish. With program blocks, you can control the commands that are run based on many criteria, including:

You can also read data from the active dataset to perform additional computations, update the active dataset with results, create new datasets, and create custom pivot table output.

Figure 1. Jobwise Flow Control
Jobwise Flow Control

Operations

Syntax Rules

Within a program block, the programming language is in control, and the syntax rules for that programming language apply. Command syntax generated from within program blocks must always follow interactive syntax rules. For most practical purposes this means command strings you build in a programming block must contain a period (.) at the end of each command.

Scope and Limitations

Using External Programming Languages

Use of the IBM SPSS Statistics Programmability Extension requires an Integration Plug-in for an external language. Integration Plug-ins supported for use with BEGIN PROGRAM-END PROGRAM blocks are available for the Python and R programming languages. See the topic How to Get Integration Plug-Ins for more information. Documentation for the plug-ins is available from the topics Integration Plug-in for Python and Integration Plug-in for R in the Help system.

Resources for use with Integration Plug-ins are available on the IBM SPSS Predictive Analytics community at https://developer.ibm.com/predictiveanalytics/. Many of the resources are packaged as extension bundles that you can download from the Extension Hub. It is available from the menus by choosing Extensions>Extension Hub.