Get an alert when an SPSS Statistics production job fails
An IBM SPSS Statistics production job (.spj) runs on a schedule with --production … silent. A syntax error, a missing file or a failed GET DATA ends up in the job's output, while the job may carry on and the scheduler sees nothing. A few lines of Python inside the syntax catch the error and send it to you.
How production jobs handle errors
A production job runs one or more syntax files without the user interface. IBM's documentation for SPSS Statistics 31 shows how to start one from the command line, for example stats.exe --production C:\jobs\monthly.spj silent (IBM's page also lists the switch as -production), which is what you put in Task Scheduler. Note that a command-line production job can't run while the Statistics application is open on the same machine.
For each syntax file in the job you choose what happens after an error: Continue processing after errors or Stop processing immediately. With "continue", a failed command is reported in the output and the next commands run on whatever data is there, so the job can finish with empty or stale results. With "stop", processing ends, but either way the result is in the output file, not in something the scheduler understands.
IBM's documentation doesn't describe a non-zero exit code for a failed production job. Users have posted job logs that say terminated with exit code 0 right below an exception (IBM Community, 2022). Treat the exit code as unreliable and report the result yourself. As always, a job that never started — the PC was off, a license server didn't answer — leaves no output at all.
Report from inside the syntax
SPSS Statistics runs Python 3 inside the syntax with BEGIN PROGRAM PYTHON3. The code below pings TaskBeacon at the start, runs your syntax through spss.Submit, and if SPSS raises an error, sends /fail with the message. When the syntax ends well, it sends the number of cases in the active dataset.
* --- TaskBeacon: SPSS Statistics with the Python 3 integration ---.
BEGIN PROGRAM PYTHON3.
import json, urllib.request
import spss
TB = "https://taskbeacon.io/ping/your-job-id"
def tb_ping(path="", data=None):
body = json.dumps(data).encode() if data else None
req = urllib.request.Request(TB + path, data=body, headers={"Content-Type": "application/json"})
try:
urllib.request.urlopen(req, timeout=10)
except Exception as e:
print("TaskBeacon ping failed:", e)
tb_ping("/start")
try:
spss.Submit(r"""
* --- your syntax here (the example data: replace it, e.g. GET FILE='C:\data\sales.sav'.) ---.
DATA LIST FREE / amount.
BEGIN DATA
12.5 7 3
END DATA.
""")
except spss.SpssError as e:
tb_ping("/fail", {"error": str(e)[:200]})
raise
tb_ping("", {"rows": spss.GetCaseCount()})
END PROGRAM.Not yet tested on a real installation — tell us how it went. The code follows the vendor's documentation. Write to support@taskbeacon.io.
In the app, the Code tab of your job gives you this code with the job's own address instead of your-job-id, and you can untick the parts you don't need.
Put your syntax between the triple quotes, in place of the example DATA LIST. When SPSS reports an error while running that block, spss.Submit raises spss.SpssError, the code sends /fail and re-raises it. The SPSS page in the Docs has the production job setup and common problems.
What you get
- Failed with the SPSS error message, as soon as the job reaches the failing command.
- Missed when the job didn't report by its planned time plus grace, including runs that never started.
- Late when it started and is taking much longer than usual.
- Odd data when the case count drops more than 40% below the recent runs or is 0, which catches a
GET FILEthat read an empty extract.
Without TaskBeacon
Set the syntax files to Stop processing immediately, write the output to a fixed file, and have a small script (Python or PowerShell) search that file for error lines after the job ends and send an email through your SMTP server. That reports errors; for runs that never started you also need a check of the output file's date. See also SAS batch job errors and Stata do-file errors, which have the same shape.
Connected Claude or ChatGPT to TaskBeacon? Ask it "what failed last night, and why?" and it answers from your jobs. How that works.
Related
In the Docs: SPSS · Python · Statuses.
- Get an alert when a SAS batch job ends with errorsSAS returns 1 for warnings and 2 for errors, but only if someone looks.
- Get an alert when a Stata do-file fails in batch modeStata /e and -b don't report a failed do-file to the scheduler.
- Get an alert when a job loads 0 rows, or far fewer than usualExit code 0 says nothing about how many rows arrived.
TaskBeacon is free to start, with every feature open for now and no credit card. Create a job, paste the code, and the first ping shows up on the job page.
Start free View live demoSources
- IBM Docs, SPSS Statistics 31: Running production jobs from a command line (version 31, undated; checked 2026-11-09)
- IBM Docs, SPSS Statistics 31: Syntax files in a production job (continue or stop after errors) (version 31, undated; checked 2026-11-09)
- IBM Community: Production Facility NullPointerException (log says exit code 0) (2022-06-06, old: a sign of the problem)
Page checked against its sources on 2026-11-09. Menus and limits of other products change; if something here no longer matches, write to support@taskbeacon.io.