Search code examples
pythonspss

Using information from built-in procedure SPSS for custom procedure


I want to create a custom dialog box in SPSS to implement a new procedure that I developed. I have written the Python code for it and am now looking into creating the custom dialog box.

However, my procedure uses the regression coefficients from a data set that are derived from the built-in regression procedure. Since I want to minimize manual procedures, I want to prevent that the user first has to run regression and then has to manually input the regression coefficients in the new custom procedure.

I would prefer that I could call the built-in regression procedure in my Python code. Is this possible?

Alternatively, I thought inserting the code to calculate the regression coefficients withing my Python code. But I prefer not, as this code is very long and if there is a built-in procedure already, I hope to find a way to take advantage of that.


Solution

  • The basic idea is to use the spss.Submit API to run regular commands but wrapped in OMS commands so that you can get their output as a dataset or xml structure. You can keep this output from appearing at all in the Viewer, or you can let it appear.

    If it is elaborate, you might, as Andy said, want to make it an extension command, including a custom dialog, but this is not always necessary.