Re: Use pivot tables from output as new input
Posted by
Jon K Peck on
May 16, 2011; 10:04pm
URL: http://spssx-discussion.165.s1.nabble.com/Use-pivot-tables-from-output-as-new-input-tp4397439p4401839.html
Yes, you can retrieve a pivot table and
create a dataset from it using scripting, but it's more efficient to do
this with OMS. The script would locate the table, query the data
cells, and use the programmability apis to build the cases for a new dataset.
Not hard to do, but I don't know of any full examples, since it is
an unusual way of proceeding.
You don't need to use the scripting
window at all in order to use Python. Just put the program code between
BEGIN PROGRAM and END PROGRAM statements.
Jon Peck
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621
From:
John Test <[hidden email]>
To:
[hidden email]
Date:
05/16/2011 03:55 PM
Subject:
Re: [SPSSX-L]
Use pivot tables from output as new input
Sent by:
"SPSSX(r)
Discussion" <[hidden email]>
Hi and thanks!
Great idea!
Question: Is it also possible to use a table in an output viewer without
re running the analysis for use in such a python script?
Is there maybe a script available which uses a selected table in the
output viewer as input and transfer all the rows and column to a new
dataset as a more general approach?
THANKS!!!
P.S.: you wrote: python (running within syntax): thus, is it possible to
run python in the syntax window, too, or do we need the script window
(spss19)? Thanks again
Why don't you simply use python (within SPSS)? With python (running within
SPSS Syntax) you can easily read in your table results. This is how the
syntax looks like (german version SPSS17):
BEGIN PROGRAM.
import spss,spssaux
spss.Submit("GET FILE='C:/<path>/file.sav'.")
cmd="DESCRIPTIVES VARIABLES=Schicht,Geschlecht,Alter,Bewertung."
desc_table,errcode=spssaux.CreateXMLOutput(
cmd,
omsid="Descriptives")
meansal=spssaux.GetValuesFromXMLWorkspace(
desc_table,
tableSubtype="Descriptive Statistics",
rowCategory="Bewertung",
colCategory="Mittelwert",
cellAttrib="text")
if meansal:
print "Der Mittelwert
von Bewertung ist: ", meansal[0]
END PROGRAM.
=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD