Date: Tue, 13 Mar 2012 09:30:47 -0600
Reply-To: Jon K Peck <peck@us.ibm.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Jon K Peck <peck@us.ibm.com>
Subject: Re: Question about spssaux2 and V20
In-Reply-To: <H00005df056173fb.1331644176.masstatepolice.pol.state.ma.us@MHS>
Content-Type: multipart/alternative;
See below
Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
peck@us.ibm.com
new phone: 720-342-5621
From: "Bibel, Daniel (POL)" <daniel.bibel@state.ma.us>
To: SPSSX-L@listserv.uga.edu
Date: 03/13/2012 08:13 AM
Subject: [SPSSX-L] Question about spssaux2 and V20
Sent by: "SPSSX(r) Discussion" <SPSSX-L@listserv.uga.edu>
I've just installed a trial version of V20 and come across a piece of code
that doesn't work as it did in V18.
I have a file with monthly data from agencies. I want to split the files
by variable ('agency') and save the output into separate Excel files. I've
installed the Python essentials and copied the spssaux2.py file from the
c:\python26 directory into the c:\python27 directory.
>>>I would always recommend getting the latest version of a supplementary
file from the SPSS Community website rather than copying an old version,
although in this case, it makes the behavior comparison simpler.
The code that worked previously is:
>begin program.
>import spss, spssaux2
>cmd = "SAVE TRANSLATE
OUTFILE='U:/cru_data/SummaryReports/monthly0011/%(splitvalue)s.xls'
/TYPE=XLS /VERSION=8 /replace /fieldnames /replace "
>spssaux2.generalizedSplit('Agency', cmd)
>end program.
The output I get now is like this:
begin program.
import spss, spssaux2
cmd = "SAVE TRANSLATE
OUTFILE='U:/cru_data/SummaryReports/monthly0011/%(splitvalue)s.xls'
/TYPE=XLS /VERSION=8 /replace /fieldnames /replace "
spssaux2.generalizedSplit('Agency', cmd)
end program.
SPLIT: Agency = Abington
>Error # 9016 in column 28. Text:
U:/cru_data/SummaryReports/monthly0011/"Abington".xls >The file
specification is invalid, and the output file cannot be opened. >Execution
of this command stops.
Any suggestions greatly appreciated!
>>>I don't think this code could have worked in V18 with a string
variable. The split values for strings are quoted, and the quotes are
causing the problem in the output file name. In fact, I tried a similar
example with V18 and got the same failure.
You might be interested in the SPSSINC SPLIT DATASET extension command,
which provides a more general way to do this type of operation and doesn't
require you to write any Python code.
generalizedsplit could be modified to allow a reference to the unquoted
value, but SPLIT DATASET provides a more powerful tool.
HTH,
Jon Peck
Dan Bibel
Massachusetts State Police
[text/html]