Multiple outputs, Python, and excel

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Multiple outputs, Python, and excel

Mike P-5
Hi All,

I currently have a syntax file that creates lots of tables for analysis,
this has been set-up fine.

What I am looking to do is run repeat filters on this syntax file to
create say (for ease of use) 3 different outputs, now the problem arises
because it is not on one variables with 3 options (Thus the split file
wouldn't work, and wouldn't be suitable as seen later).

The three filters are dichotomous variables, and I want to run the
filters against my syntax file, (i.e. select f1 =1, then G3=1 etc)
create a different output window for each of the filters, and then
export these to excel.

My thoughts on how to do this would be using a python programme and
using OMS or the xml workspace? saving to excel and using an insert file
command in the python, but being no expert in python I'm a little
stumped, does anybody have any suggestion, whether it be it using python
or not.

Below is a 'Guess' of what the python code might look like or at least
the logic as I'm not fully sure of what to do.

DEFINE FNAMES () *SPECIFYING THE DIFFERENT FILTER VARIABLES IN A MACRO
F1 G3 H2
!ENDDEFINE.

*THEN BEGIN THE PYTHON PROGRAMME

begin program.
import spss,spssaux
spss.Submit("GET FILE = 'C:/Program Files/SPSS/Employee data.sav'.")
*GET THE DATA SET BEING USED

*RUN THE FILTER NEEDED AROUND THE FILE.
varList=[]
        for I in range
        '''USE ALL.
        COMPUTE filter_$=(FNAMES).
        VARIABLE LABEL filter_$ 'Filter running'.
        VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
        FORMAT filter_$ (f1.0).
        FILTER BY filter_$.
        EXECUTE .'''

*Send all output to the workspace
tables=spssaux.CreateXMLOutput(
                        cmd,
                        omsid="Descriptives")
*Run the syntax file to create output.
'''INSERT FILE='C:\projects\syntax file that works.sps'
  SYNTAX=interactive  CD=NO.'''

Then my guess would be to save the excel files based on the variable
name, then iteratively loop through this for each variable in the Fnames
Macro.

As I say I'm not very good with python so if anyone has any ideas all
help is welcome, contacted privately I can supply some example data and
a copy of the syntax file that creates all the tables.

Cheers again

Mike









END PROGRAM.

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________