How to combine descriptives and display variables

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

How to combine descriptives and display variables

P.van Groenestijn
Dear list members,

I wonder how to make a syntax or macro to combine the output of
discriptives and display variables.
To put it more exactly: I would like an output with: Variable name, N,
Minimum,  Maximum, Mean, St deviation, Format and Missing Values.
Furthermore this output should contain ALL variables in de SAME ORDER as in
the datafile.

Any help will be highly appreciated!

Pieter van Groenestijn
University of Nijmegen
The Netherlands

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: How to combine descriptives and display variables

Peck, Jon
There are three possibilities that should come close.

1. If  you have SPSS Statistics 17, take a look at the new built-in CODEBOOK command (on Analyze>Reports in the menus).  You will have to see whether the layout suits your needs.  The variable order can be as listed, file, or alphabetical.

2. If you are on SPSS 16, consider the CODEBOOK extension command.  (Usable also with 17, but it needs renaming to avoid conflicting with the built-in command.)  This extension command can be downloaded from SPSS Developer Central, www.spss.com/devcentral.  It requires the Python programmability plug-in.  It does not have a dialog box interface as the Custom Dialog Builder is a new feature of version 17.

3. If you have a very specific single table layout in mind or are on version 14 or 15, you would need to use programmability to construct a custom pivot table with that layout.

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Pieter van Groenestijn
Sent: Tuesday, December 23, 2008 7:04 AM
To: [hidden email]
Subject: [SPSSX-L] How to combine descriptives and display variables

Dear list members,

I wonder how to make a syntax or macro to combine the output of
discriptives and display variables.
To put it more exactly: I would like an output with: Variable name, N,
Minimum,  Maximum, Mean, St deviation, Format and Missing Values.
Furthermore this output should contain ALL variables in de SAME ORDER as in
the datafile.

Any help will be highly appreciated!

Pieter van Groenestijn
University of Nijmegen
The Netherlands

=====================
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

=====================
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
Reply | Threaded
Open this post in threaded view
|

What happend to SPSS 16 and 17?

Johnny Amora
Hi all,
 
Have you tried the following in SPSS 16 and 17?
 
1. In the pivot table, there are times that not all "highlighted numeric entries" in the table cannot be copied and pasted to MS word.  Only fraction of the highlighted entries will appear on the MS word after executing the copy and paste commands. But all these things are easily done using vesion 15. Moreover, in the pivot table with values expressed in three or more decimal places, when such values are highlighted in order to reset them into two decimal places using the cell properties command, the result is discouraging because only fractions of the highlighted values will be changed to 2 decimal places.
 
2. No more "statistics coach" in version 16 and 17.  In version 15 and below, you can just right click the output if you need the help of the "statistics coach".  ( I already deleted my version 15.  I cannot recall exactly the right term; its something like "statistics coach")
 
What happend to SPSS 16 and 17.  Thanks for reading.
 
Johnny


      Happy Holidays from Yahoo! Messenger. Spread holiday cheers to your friends and loved ones today! Get started at http://emoticarolers.com/

====================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
Reply | Threaded
Open this post in threaded view
|

Changing decimal places in frequency tables

Thew, Barbara
In reply to this post by Peck, Jon
Hi

Spss16

Can you tell me how to change to 2 decimal places in a frequency table
please

Thanks

Barbara
 From phone


On 27 Dec 2008, at 01:11, "Peck, Jon" <[hidden email]> wrote:

> There are three possibilities that should come close.
>
> 1. If  you have SPSS Statistics 17, take a look at the new built-in
> CODEBOOK command (on Analyze>Reports in the menus).  You will have
> to see whether the layout suits your needs.  The variable order can
> be as listed, file, or alphabetical.
>
> 2. If you are on SPSS 16, consider the CODEBOOK extension command.
> (Usable also with 17, but it needs renaming to avoid conflicting
> with the built-in command.)  This extension command can be
> downloaded from SPSS Developer Central, www.spss.com/devcentral.  It
> requires the Python programmability plug-in.  It does not have a
> dialog box interface as the Custom Dialog Builder is a new feature
> of version 17.
>
> 3. If you have a very specific single table layout in mind or are on
> version 14 or 15, you would need to use programmability to construct
> a custom pivot table with that layout.
>
> HTH,
> Jon Peck
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On
> Behalf Of Pieter van Groenestijn
> Sent: Tuesday, December 23, 2008 7:04 AM
> To: [hidden email]
> Subject: [SPSSX-L] How to combine descriptives and display variables
>
> Dear list members,
>
> I wonder how to make a syntax or macro to combine the output of
> discriptives and display variables.
> To put it more exactly: I would like an output with: Variable name, N,
> Minimum,  Maximum, Mean, St deviation, Format and Missing Values.
> Furthermore this output should contain ALL variables in de SAME
> ORDER as in
> the datafile.
>
> Any help will be highly appreciated!
>
> Pieter van Groenestijn
> University of Nijmegen
> The Netherlands
>
> =====================
> 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
>
> =====================
> 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

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Changing decimal places in frequency tables

Maguin, Eugene
Barbara,

Basically, you want to edit the cell properties. So, select the table,
double-click (left) to open it, select the cells you want it to apply to and
right click, select cell properties and then the format values tab. That
said, this does not work for me for a frequency table of computed values
when using 16.02. (Instead, I get 17-18 decimal places. Ah yes, a
never-to-be-fixed error.)

Somebody more skillful can tell you how to do this for all tables because
this is a table by table fix.

Gene Maguin


>>Can you tell me how to change to 2 decimal places in a frequency table
please

=====================
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
Reply | Threaded
Open this post in threaded view
|

if command line created in python is too long for spss

mpirritano
In reply to this post by Thew, Barbara
If have a situation where my filename is very long. If I try to open
this file from python I get the following error message.

>A text string is not correctly enclosed in quotation marks on the
command
>line.  Literals may not be continued across command lines without the
use >of the continuation symbol '+'.

My get file statement in python looks like this:

spss.Submit("GET FILE='G:/Data/AMM/SPSS Files/" + recent_date + "'.")

Recent_date is the filename which is very long. So I'm assuming I need
to put a '+' somewhere in the filename. Wouldn't the '+' usually go at
the beginning of a new line? Forgive me, I don't use '+' in spss syntax
much. The question is, regardless of where the '+' should go in spss,
how do you know where to put it in python? Do I need to count characters
or something like that?

Thanks
Matt

Matthew Pirritano, Ph.D.
Research Analyst IV
Medical Services Initiative (MSI)
Orange County Health Care Agency
(714) 834-3566

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: if command line created in python is too long for spss

Peck, Jon
Python  has no limit on the line length, but you are restricted to the SPSS line length limit when running a Python program within SPSS, including Submit text.  Submit will do some wrapping, but the solutions below don't count on that.

You can break Python literals anywhere, joining with "+".
You can break your SPSS syntax anywhere, joining with "+".  This gets hard to match up, though, so the easiest thing to do is to use Python triple quotes and build your SPSS syntax  inside them, since the literals are automatically continued from line to line in Python this way.

Here's an example.

spss.Submit(r"""GET FILE=
' GET FILE='G:/Data/AMM/SPSS Files/' +
'first part of name' +
'second part of name'.""")

If recent_date is a variable that you need to substitute, the easiest way is to use the Python textwrap module to handle this.  After an
import textwrap

use this code.
wrappedname = textwrap.wrap(recent_date)    # breaks recent_date into 70-byte chunks and returns a list

recent_wrapped = "+\n".join(["'" + item + "'" for item in wrappedname])  # builds lines of SPSS literals

Then your submit would look like

spss.Submit(r"""GET FILE=
'G:/Data/AMM/SPSS Files/' +
%s.""" % recent_wrapped)

The recent_wrapped variable will be a string separated into lines with each line text in single quotes and with "+" signs in-between.

If the filename has single quotes in it, change the single quotes above into double quotes.  The Python triple quotes will not be ended until a matching triple quote appears.

I know that's a bit much for New Year's Eve, but I hope it is clear enough.

Regards,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Pirritano, Matthew
Sent: Wednesday, December 31, 2008 2:18 PM
To: [hidden email]
Subject: [SPSSX-L] if command line created in python is too long for spss

If have a situation where my filename is very long. If I try to open
this file from python I get the following error message.

>A text string is not correctly enclosed in quotation marks on the
command
>line.  Literals may not be continued across command lines without the
use >of the continuation symbol '+'.

My get file statement in python looks like this:

spss.Submit("GET FILE='G:/Data/AMM/SPSS Files/" + recent_date + "'.")

Recent_date is the filename which is very long. So I'm assuming I need
to put a '+' somewhere in the filename. Wouldn't the '+' usually go at
the beginning of a new line? Forgive me, I don't use '+' in spss syntax
much. The question is, regardless of where the '+' should go in spss,
how do you know where to put it in python? Do I need to count characters
or something like that?

Thanks
Matt

Matthew Pirritano, Ph.D.
Research Analyst IV
Medical Services Initiative (MSI)
Orange County Health Care Agency
(714) 834-3566

=====================
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

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: if command line created in python is too long for spss

Oliver, Richard
In reply to this post by mpirritano
I don't think length is an issue here. I think the issue is an invalid SPSS GET command.
 
Try something like this instead:
 
recent_date="file spec"
spss.Submit("""
get file='G:/Data/AMM/SPSS Files/%(recent_date)s'.
"""%locals())
 

________________________________

From: SPSSX(r) Discussion on behalf of Pirritano, Matthew
Sent: Wed 12/31/2008 3:18 PM
To: [hidden email]
Subject: if command line created in python is too long for spss



If have a situation where my filename is very long. If I try to open
this file from python I get the following error message.

>A text string is not correctly enclosed in quotation marks on the
command
>line.  Literals may not be continued across command lines without the
use >of the continuation symbol '+'.

My get file statement in python looks like this:

spss.Submit("GET FILE='G:/Data/AMM/SPSS Files/" + recent_date + "'.")

Recent_date is the filename which is very long. So I'm assuming I need
to put a '+' somewhere in the filename. Wouldn't the '+' usually go at
the beginning of a new line? Forgive me, I don't use '+' in spss syntax
much. The question is, regardless of where the '+' should go in spss,
how do you know where to put it in python? Do I need to count characters
or something like that?

Thanks
Matt

Matthew Pirritano, Ph.D.
Research Analyst IV
Medical Services Initiative (MSI)
Orange County Health Care Agency
(714) 834-3566

=====================
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

====================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
Reply | Threaded
Open this post in threaded view
|

Re: if command line created in python is too long for spss

Peck, Jon
In reply to this post by Peck, Jon
I did a few experiments with long lines and Submit, and to my surprise, even very long lines worked.  So maybe all the folderol below is actually unnecessary.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peck, Jon
Sent: Wednesday, December 31, 2008 3:40 PM
To: [hidden email]
Subject: Re: [SPSSX-L] if command line created in python is too long for spss

Python  has no limit on the line length, but you are restricted to the SPSS line length limit when running a Python program within SPSS, including Submit text.  Submit will do some wrapping, but the solutions below don't count on that.

You can break Python literals anywhere, joining with "+".
You can break your SPSS syntax anywhere, joining with "+".  This gets hard to match up, though, so the easiest thing to do is to use Python triple quotes and build your SPSS syntax  inside them, since the literals are automatically continued from line to line in Python this way.

Here's an example.

spss.Submit(r"""GET FILE=
' GET FILE='G:/Data/AMM/SPSS Files/' +
'first part of name' +
'second part of name'.""")

If recent_date is a variable that you need to substitute, the easiest way is to use the Python textwrap module to handle this.  After an
import textwrap

use this code.
wrappedname = textwrap.wrap(recent_date)    # breaks recent_date into 70-byte chunks and returns a list

recent_wrapped = "+\n".join(["'" + item + "'" for item in wrappedname])  # builds lines of SPSS literals

Then your submit would look like

spss.Submit(r"""GET FILE=
'G:/Data/AMM/SPSS Files/' +
%s.""" % recent_wrapped)

The recent_wrapped variable will be a string separated into lines with each line text in single quotes and with "+" signs in-between.

If the filename has single quotes in it, change the single quotes above into double quotes.  The Python triple quotes will not be ended until a matching triple quote appears.

I know that's a bit much for New Year's Eve, but I hope it is clear enough.

Regards,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Pirritano, Matthew
Sent: Wednesday, December 31, 2008 2:18 PM
To: [hidden email]
Subject: [SPSSX-L] if command line created in python is too long for spss

If have a situation where my filename is very long. If I try to open
this file from python I get the following error message.

>A text string is not correctly enclosed in quotation marks on the
command
>line.  Literals may not be continued across command lines without the
use >of the continuation symbol '+'.

My get file statement in python looks like this:

spss.Submit("GET FILE='G:/Data/AMM/SPSS Files/" + recent_date + "'.")

Recent_date is the filename which is very long. So I'm assuming I need
to put a '+' somewhere in the filename. Wouldn't the '+' usually go at
the beginning of a new line? Forgive me, I don't use '+' in spss syntax
much. The question is, regardless of where the '+' should go in spss,
how do you know where to put it in python? Do I need to count characters
or something like that?

Thanks
Matt

Matthew Pirritano, Ph.D.
Research Analyst IV
Medical Services Initiative (MSI)
Orange County Health Care Agency
(714) 834-3566

=====================
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

=====================
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

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: if command line created in python is too long for spss

mpirritano
Is it possible that it is not that the submit line is long but that the file name that is called is very long. I'm very new to python so I apologize in advance if my question betrays my naïveté.

I apologize for not having included the first 2 lines in previous post perhaps that lead to some misunderstanding. The file that is opened, ammfiles.txt, includes only the name of the most recent file. The filename is, MSI_Data_102108_basiclyclean_saveinpatient_allsites.sav. My original syntax was:

outlist = open(r"c:\text\ammfiles.txt","r")
recent_date = outlist.readline()

print recent_date

import spss

spss.Submit("GET FILE='G:/Data/AMM/SPSS Files/" + recent_date + "'")

And here is all of the output. Notice that it prints the filename correctly but in the first Warning it appears to be truncating the filename, which I'm guessing may be why it returns the error. Output follows:

MSI_Data_102108_basiclyclean_saveinpatient_allsites.sav


>Warning # 208 in column 10.  Text: G:/Data/AMM/SPSS_Files/ >+MSI_Data_102108_basiclyclean_saveinpatien

[NB: notice that the filename above is truncated in this error message. Truncated at 74 characters]

>A text string is not correctly enclosed in quotation marks on the command
>line.  Literals may not be continued across command lines without the use >of the continuation symbol '+'.

>Warning # 208 in column 1.  Text: ' '
>A text string is not correctly enclosed in quotation marks on the command
>line.  Literals may not be continued across command lines without the use >of the continuation symbol '+'.

>Error # 63 in column 10.  Text: >G:/Data/AMM/SPSS_Files/MSI_Data_102108_basiclyclean_saveinpatien
>The file does not exist.
>This command not executed.
Traceback (most recent call last):
  File "cleaning2.py", line 24, in <module>
    spss.Submit("GET FILE='G:/Data/AMM/SPSS_Files/" + recent_date + "'.")
  File "C:\Python25\lib\site-packages\spss170\spss\spss.py", line 1241, in Submit
    raise SpssError,error
spss.errMsg.SpssError: [errLevel 3] Serious error.

I get the same output if I use this alternative syntax:

outlist = open(r"c:\text\ammfiles.txt","r")
recent_date = outlist.readline()

print recent_date

import spss

spss.Submit("""
GET FILE='G:/Data/AMM/SPSS_Files/%s'
"""% recent_date)

The same syntax runs with no problem if I manually substitute the filename and enter it into an spss syntax window.

Any advice much appreciated.
Thanks
Matt


Matthew Pirritano, Ph.D.
Research Analyst IV
Medical Services Initiative (MSI)
Orange County Health Care Agency
(714) 834-3566
-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peck, Jon
Sent: Wednesday, December 31, 2008 6:32 PM
To: [hidden email]
Subject: Re: if command line created in python is too long for spss

I did a few experiments with long lines and Submit, and to my surprise, even very long lines worked.  So maybe all the folderol below is actually unnecessary.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peck, Jon
Sent: Wednesday, December 31, 2008 3:40 PM
To: [hidden email]
Subject: Re: [SPSSX-L] if command line created in python is too long for spss

Python  has no limit on the line length, but you are restricted to the SPSS line length limit when running a Python program within SPSS, including Submit text.  Submit will do some wrapping, but the solutions below don't count on that.

You can break Python literals anywhere, joining with "+".
You can break your SPSS syntax anywhere, joining with "+".  This gets hard to match up, though, so the easiest thing to do is to use Python triple quotes and build your SPSS syntax  inside them, since the literals are automatically continued from line to line in Python this way.

Here's an example.

spss.Submit(r"""GET FILE=
' GET FILE='G:/Data/AMM/SPSS Files/' +
'first part of name' +
'second part of name'.""")

If recent_date is a variable that you need to substitute, the easiest way is to use the Python textwrap module to handle this.  After an
import textwrap

use this code.
wrappedname = textwrap.wrap(recent_date)    # breaks recent_date into 70-byte chunks and returns a list

recent_wrapped = "+\n".join(["'" + item + "'" for item in wrappedname])  # builds lines of SPSS literals

Then your submit would look like

spss.Submit(r"""GET FILE=
'G:/Data/AMM/SPSS Files/' +
%s.""" % recent_wrapped)

The recent_wrapped variable will be a string separated into lines with each line text in single quotes and with "+" signs in-between.

If the filename has single quotes in it, change the single quotes above into double quotes.  The Python triple quotes will not be ended until a matching triple quote appears.

I know that's a bit much for New Year's Eve, but I hope it is clear enough.

Regards,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Pirritano, Matthew
Sent: Wednesday, December 31, 2008 2:18 PM
To: [hidden email]
Subject: [SPSSX-L] if command line created in python is too long for spss

If have a situation where my filename is very long. If I try to open
this file from python I get the following error message.

>A text string is not correctly enclosed in quotation marks on the
command
>line.  Literals may not be continued across command lines without the
use >of the continuation symbol '+'.

My get file statement in python looks like this:

spss.Submit("GET FILE='G:/Data/AMM/SPSS Files/" + recent_date + "'.")

Recent_date is the filename which is very long. So I'm assuming I need
to put a '+' somewhere in the filename. Wouldn't the '+' usually go at
the beginning of a new line? Forgive me, I don't use '+' in spss syntax
much. The question is, regardless of where the '+' should go in spss,
how do you know where to put it in python? Do I need to count characters
or something like that?

Thanks
Matt

Matthew Pirritano, Ph.D.
Research Analyst IV
Medical Services Initiative (MSI)
Orange County Health Care Agency
(714) 834-3566

=====================
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

=====================
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

=====================
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

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: if command line created in python is too long for spss

mpirritano
In reply to this post by Peck, Jon
Jon,

Thanks, I hadn't noticed the solution you provided. I finally got it to
work with that solution using textwrap!

Thanks
matt

Matthew Pirritano, Ph.D.
Research Analyst IV
Medical Services Initiative (MSI)
Orange County Health Care Agency
(714) 834-3566

-----Original Message-----
From: Peck, Jon [mailto:[hidden email]]
Sent: Wednesday, December 31, 2008 2:40 PM
To: Pirritano, Matthew; [hidden email]
Subject: RE: [SPSSX-L] if command line created in python is too long for
spss

Python  has no limit on the line length, but you are restricted to the
SPSS line length limit when running a Python program within SPSS,
including Submit text.  Submit will do some wrapping, but the solutions
below don't count on that.

You can break Python literals anywhere, joining with "+".
You can break your SPSS syntax anywhere, joining with "+".  This gets
hard to match up, though, so the easiest thing to do is to use Python
triple quotes and build your SPSS syntax  inside them, since the
literals are automatically continued from line to line in Python this
way.

Here's an example.

spss.Submit(r"""GET FILE=
' GET FILE='G:/Data/AMM/SPSS Files/' +
'first part of name' +
'second part of name'.""")

If recent_date is a variable that you need to substitute, the easiest
way is to use the Python textwrap module to handle this.  After an
import textwrap

use this code.
wrappedname = textwrap.wrap(recent_date)    # breaks recent_date into
70-byte chunks and returns a list

recent_wrapped = "+\n".join(["'" + item + "'" for item in wrappedname])
# builds lines of SPSS literals

Then your submit would look like

spss.Submit(r"""GET FILE=
'G:/Data/AMM/SPSS Files/' +
%s.""" % recent_wrapped)

The recent_wrapped variable will be a string separated into lines with
each line text in single quotes and with "+" signs in-between.

If the filename has single quotes in it, change the single quotes above
into double quotes.  The Python triple quotes will not be ended until a
matching triple quote appears.

I know that's a bit much for New Year's Eve, but I hope it is clear
enough.

Regards,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Pirritano, Matthew
Sent: Wednesday, December 31, 2008 2:18 PM
To: [hidden email]
Subject: [SPSSX-L] if command line created in python is too long for
spss

If have a situation where my filename is very long. If I try to open
this file from python I get the following error message.

>A text string is not correctly enclosed in quotation marks on the
command
>line.  Literals may not be continued across command lines without the
use >of the continuation symbol '+'.

My get file statement in python looks like this:

spss.Submit("GET FILE='G:/Data/AMM/SPSS Files/" + recent_date + "'.")

Recent_date is the filename which is very long. So I'm assuming I need
to put a '+' somewhere in the filename. Wouldn't the '+' usually go at
the beginning of a new line? Forgive me, I don't use '+' in spss syntax
much. The question is, regardless of where the '+' should go in spss,
how do you know where to put it in python? Do I need to count characters
or something like that?

Thanks
Matt

Matthew Pirritano, Ph.D.
Research Analyst IV
Medical Services Initiative (MSI)
Orange County Health Care Agency
(714) 834-3566

=====================
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

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: What happend to SPSS 16 and 17?

Lombardo, Barbara
In reply to this post by Johnny Amora
I have been wondering the same thing "what happened to SPSS".  I have used the product for 14 years and never had a problem with any of the new releases until release 16.  Although we have 16 and 17 and am still using 15.  Please SPSS bring back quality control!

Barbara

 Think before you print.

CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited. If you received this e-mail in error, please notify the sender and delete this e-mail from your system.


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Johnny Amora
Sent: Friday, December 26, 2008 10:42 PM
To: [hidden email]
Subject: What happend to SPSS 16 and 17?

Hi all,

Have you tried the following in SPSS 16 and 17?

1. In the pivot table, there are times that� not all "highlighted numeric entries" in the table cannot be copied and� pasted to MS word.�  Only fraction of the highlighted entries will appear on the MS word after executing the copy and paste commands.� But all these things are easily done using� vesion 15.� Moreover,� in the pivot table with values expressed in three or more decimal places, when� such� values are� highlighted in order to reset� them into two decimal places using the cell properties command, the result� is discouraging because only fractions� of the highlighted� values will be� changed to� 2 decimal places.

2. No more� "statistics coach" in version 16 and 17.�  In version 15 and below, you can just right click the output if you need the help of the "statistics coach".�  ( I already deleted my version 15.�  I cannot recall exactly the right term; its something like "statistics coach")

What happend to SPSS 16 and 17.�  Thanks for reading.

Johnny


      Happy Holidays from Yahoo! Messenger. Spread holiday cheers to your friends and loved ones today! Get started at http://emoticarolers.com/

=======
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

=====================
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