spss.StopSPSS Function (Python)
spss.StopSPSS(). Stops IBM® SPSS® Statistics, ending the session.
- This function is ignored when running Python from IBM SPSS Statistics (within
program blocks defined by
BEGIN PROGRAM-END PROGRAM
). - When running IBM SPSS Statistics from
Python, this function ends the IBM SPSS Statistics session,
and any subsequent
spss.Submit
functions that restart IBM SPSS Statistics will not have access to the active dataset or to any other session-specific settings (for example,OMS
output routing commands) from the previous session. See the topic spss.Submit Function (Python) for more information.
Example: Running IBM SPSS Statistics from Python
import spss
#start a session and run some commands
#including one that defines an active dataset
spss.Submit("""
GET FILE '/examples/data/employee data.sav'.
FREQUENCIES VARIABLES=gender jobcat.
""")
#shutdown the session
spss.StopSPSS()
#insert a bunch of Python statements
#starting a new session and running some commands without defining
#an active dataset results in an error
spss.Submit("""
FREQUENCIES VARIABLES=gender jobcat.
""")
Example: Running Python from IBM SPSS Statistics
BEGIN PROGRAM.
import spss
#start a session and run some commands
#including one that defines an active dataset
spss.Submit("""
GET FILE '/examples/data/employee data.sav'.
FREQUENCIES VARIABLES=gender jobcat.
""")
#following function is ignored
spss.StopSPSS()
#active dataset still exists and subsequent spss.Submit functions
#will work with that active dataset.
spss.Submit("""
FREQUENCIES VARIABLES=gender jobcat.
""")
END PROGRAM.