Sunday, December 21, 2008

SPSS: programing SPSS with Python (part 1)

SPSS is a data mining and statistical analysis software. Resent versions (v14 - v17) allow to use Python to control SPSS. This can be quite handy, especially if there are lots of variables and lots of data files to analyze and such analysis is often repeated. In such a case, writing some script in Python that can execute SPSS analysis automatically can save you lots of time. This is the first post out of three, which will present some example of using Python and SPSS together. First, let me present what soft and hardware I have:
  • Intel Mac X 10.4.11
  • SPSS 16.0.1 with SPSS-Python Integration Plug-In
  • Python 2.5

Check if SPSS-Python Integration Plug-In works

Before we can proceed any further we have to check if SPSS-Python Integration Plug-In is working, and we can control SPSS using Python. To do this I usually use the following procedure:
1. Start SPSS.
2. Create new script (File->New->Script):
This results in a python IDLE console:
3. Try to import spss library and execute some simple spss function (e.g. spss.GetVariableCount()):
This resulted in 0 which is OK, because we do not have any active dataset.

So it appears that SPSS-Python union is working. Therefore, we can do something useful now.

Note

More information on SPSS-Python programming along with examples can be found in SPSS Programming and Data Management.

3 comments:

  1. Anonymous9:48 PM

    It's going to be ending of mine day, but before ending I am reading this impressive piece of writing to improve my experience.

    Check out my website - lose weight

    ReplyDelete
  2. Anonymous3:53 AM

    Ӏ like the helpful info you pгоvide in youг агticles.
    I will bookmark yοur blog and сheck agаin heгe frequently.
    I am quitе certаin I'll learn a lot of new stuff right here! Best of luck for the next!

    my web blog - paying off credit card debt

    ReplyDelete