Make bold or in color sign. correlations in output

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

Make bold or in color sign. correlations in output

msherman
Dear List, I have been looking for a script that would color or make
bold all correlations in a correlation output table that are significant
but have been unsuccessful. Is anyone aware of  such a script?  thanks,
martin sherman

Martin F. Sherman, Ph.D.
Professor of Psychology
Director of Masters Education: Thesis Track
Loyola College
222 B Beatty Hall
4501 North Charles Street
Baltimore, MD 21210

410 617-2417 (Office)
410 617-5341 (FAX)
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Make bold or in color sign. correlations in output

Parry, James
Hi Martin (and list!),

There is a script that comes with SPSS called 'Correlations_Table_Correlations_Create' that 1) omits the top part of the diagonal of the correlation matrix and b) highlights in yellow any significant correlations (to .01, 2-tailed).

The way to activate the autoscript is to go to Edit...Options, choose the Scripts Tab and make sure to select the second script down 'Correlations_Table_Correlations_Create'. After selecting the script, make sure to press OK, and then run correlations.

Also, if you're interested in altering any of the parameters (say significance level to be highlighted, color of highlighting or font, etc.), or if you want to make the script work for Spearman's, here is a link to an earlier, detailed explanation by one of SPSS' Statisticians:

http://www.listserv.uga.edu/cgi-bin/wa?A2=ind9811&L=spssx-l&P=2898

If anyone happens to have a version of this script in another language (Python, VB, etc.) please feel free to submit it to: http://www.spss.com/devcentral/, our new meeting place for SPSS'ers interested in powerful statistical development.


Best,

James E. Parry
Systems Engineer, SPSS




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Martin Sherman
Sent: Friday, July 21, 2006 10:21 AM
To: [hidden email]
Subject: Make bold or in color sign. correlations in output

Dear List, I have been looking for a script that would color or make
bold all correlations in a correlation output table that are significant
but have been unsuccessful. Is anyone aware of  such a script?  thanks,
martin sherman

Martin F. Sherman, Ph.D.
Professor of Psychology
Director of Masters Education: Thesis Track
Loyola College
222 B Beatty Hall
4501 North Charles Street
Baltimore, MD 21210

410 617-2417 (Office)
410 617-5341 (FAX)
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Make bold or in color sign. correlations in output

John Norton
In reply to this post by msherman
Hi List:
 
I wanted to add a caveat (or a "gotcha") to James Parry's reference to the 'Correlations_Table_Correlations_Create' script.  This is quite a useful script, but when running correlations from command language and using the WITH statement, this script will still remove the diagonal and the upper half of the matrix, regardless of the WITH statement.
 
So, for example, if you execute correlations from the dialogs with variables q1 q2 and q3, you'll get a matrix with variables q1 q2 and q3 defining both the rows and the columns.  So, in the diagonal, you'll get perfect correlations - as variables tend to do with themselves - and in the upper right corner half of the table you'll get identical correlations as you would with the variable combinations in the lower left half of the matrix.  In this case, it makes sense that the diagonals of correlations of variables with themselves, and the redundant upper corner half of the matrix be removed.
 
But if you use command language with the WITH statement:
 
CORRELATIONS
  /VARIABLES=x1 x2 x3 WITH x4 x5 x6
  /PRINT=TWOTAIL NOSIG
  /MISSING=PAIRWISE .

..you'll get a matrix with variables x1 x2 and x3 defining the rows and variables x4 x5 and x6 defining the columns.  The script will still remove the diagonal and the upper right corner half of the matrix, regardless of the fact that in this case, there are no redundancies.
 
This is more of an annoyance and a speed bump than anything else (especially if/when attempting to demonstrate correlations in class, and after forgetting that you've already demonstrated this script and left it active).  Still, it's a "gotcha" to be aware of - it's always a good idea to monitor what you automate.  :-)
 
Best,
 
John Norton
Biostatistician
Oncology Institute
Loyola University Medical Center
 
(708) 327-3095
[hidden email]
 
"Absence of evidence
      is not evidence of absence"


>>> "Parry, James" <[hidden email]> 7/24/2006 2:15 PM >>>

Hi Martin (and list!),

There is a script that comes with SPSS called 'Correlations_Table_Correlations_Create' that 1) omits the top part of the diagonal of the correlation matrix and b) highlights in yellow any significant correlations (to .01, 2-tailed).

The way to activate the autoscript is to go to Edit...Options, choose the Scripts Tab and make sure to select the second script down 'Correlations_Table_Correlations_Create'. After selecting the script, make sure to press OK, and then run correlations.

Also, if you're interested in altering any of the parameters (say significance level to be highlighted, color of highlighting or font, etc.), or if you want to make the script work for Spearman's, here is a link to an earlier, detailed explanation by one of SPSS' Statisticians:

http://www.listserv.uga.edu/cgi-bin/wa?A2=ind9811&L=spssx-l&P=2898

If anyone happens to have a version of this script in another language (Python, VB, etc.) please feel free to submit it to: http://www.spss.com/devcentral/, our new meeting place for SPSS'ers interested in powerful statistical development.


Best,

James E. Parry
Systems Engineer, SPSS
Reply | Threaded
Open this post in threaded view
|

Saving file as part of python program

Roberts, Michael
Hi all,

Would someone be able to look at this code and let me know what is
wrong?  I have tried several approaches, and although the files opened
up, the code apparently works only on the last file opened, and then
does not save it.

I selected a small sample of 5 spss formatted files in a folder to test
the program, which is supposed to open the files one by one, perform an
spss function - in this case, select the first ten cases, then save the
file with the 'nu' in front of the old file name.

I would appreciate any help you can provide with this, as none of the
documentation seems to address how to do this cyclical processing.


set printback on mprint on.
Begin Program.
import spss, glob, spssaux
savlist=glob.glob('c:/path/proj_test/tst*.sav')
for basefile in savlist:
        outfile='nu'+ basefile
        spssaux.OpenDataFile(basefile)
        spss.Submit("""compute test=10*var_1.
        save outfile='c:/path/proj_test/outfile'
/compressed.""")
End Program.

Thanks in Advance

Mike




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
John Norton
Sent: Monday, July 24, 2006 4:03 PM
To: [hidden email]
Subject: Re: Make bold or in color sign. correlations in output

Hi List:

I wanted to add a caveat (or a "gotcha") to James Parry's reference to
the 'Correlations_Table_Correlations_Create' script.  This is quite a
useful script, but when running correlations from command language and
using the WITH statement, this script will still remove the diagonal and
the upper half of the matrix, regardless of the WITH statement.

So, for example, if you execute correlations from the dialogs with
variables q1 q2 and q3, you'll get a matrix with variables q1 q2 and q3
defining both the rows and the columns.  So, in the diagonal, you'll get
perfect correlations - as variables tend to do with themselves - and in
the upper right corner half of the table you'll get identical
correlations as you would with the variable combinations in the lower
left half of the matrix.  In this case, it makes sense that the
diagonals of correlations of variables with themselves, and the
redundant upper corner half of the matrix be removed.

But if you use command language with the WITH statement:

CORRELATIONS
  /VARIABLES=x1 x2 x3 WITH x4 x5 x6
  /PRINT=TWOTAIL NOSIG
  /MISSING=PAIRWISE .

..you'll get a matrix with variables x1 x2 and x3 defining the rows and
variables x4 x5 and x6 defining the columns.  The script will still
remove the diagonal and the upper right corner half of the matrix,
regardless of the fact that in this case, there are no redundancies.

This is more of an annoyance and a speed bump than anything else
(especially if/when attempting to demonstrate correlations in class, and
after forgetting that you've already demonstrated this script and left
it active).  Still, it's a "gotcha" to be aware of - it's always a good
idea to monitor what you automate.  :-)

Best,

John Norton
Biostatistician
Oncology Institute
Loyola University Medical Center

(708) 327-3095
[hidden email]

"Absence of evidence
      is not evidence of absence"


>>> "Parry, James" <[hidden email]> 7/24/2006 2:15 PM >>>

Hi Martin (and list!),

There is a script that comes with SPSS called
'Correlations_Table_Correlations_Create' that 1) omits the top part of
the diagonal of the correlation matrix and b) highlights in yellow any
significant correlations (to .01, 2-tailed).

The way to activate the autoscript is to go to Edit...Options, choose
the Scripts Tab and make sure to select the second script down
'Correlations_Table_Correlations_Create'. After selecting the script,
make sure to press OK, and then run correlations.

Also, if you're interested in altering any of the parameters (say
significance level to be highlighted, color of highlighting or font,
etc.), or if you want to make the script work for Spearman's, here is a
link to an earlier, detailed explanation by one of SPSS' Statisticians:

http://www.listserv.uga.edu/cgi-bin/wa?A2=ind9811&L=spssx-l&P=2898

If anyone happens to have a version of this script in another language
(Python, VB, etc.) please feel free to submit it to:
http://www.spss.com/devcentral/, our new meeting place for SPSS'ers
interested in powerful statistical development.


Best,

James E. Parry
Systems Engineer, SPSS
Reply | Threaded
Open this post in threaded view
|

Re: Saving file as part of python program

Oliver, Richard
Just off the cuff, the 'outfile' within the triple quoted string will be treated as the string 'outfile' not the value of the Python variable outfile. For the triple quoted SPSS command spec try something like:

spss.Submit("""compute test=10*var_1.
save outfile='c:/path/proj_test/%s'.
""" %(outfile))

This is a general Python convention, and there are several examples of this convention in the SPSS-Python plug-in documentation.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Roberts, Michael
Sent: Monday, July 24, 2006 3:29 PM
To: [hidden email]
Subject: Saving file as part of python program

Hi all,

Would someone be able to look at this code and let me know what is wrong?  I have tried several approaches, and although the files opened up, the code apparently works only on the last file opened, and then does not save it.

I selected a small sample of 5 spss formatted files in a folder to test the program, which is supposed to open the files one by one, perform an spss function - in this case, select the first ten cases, then save the file with the 'nu' in front of the old file name.

I would appreciate any help you can provide with this, as none of the documentation seems to address how to do this cyclical processing.


set printback on mprint on.
Begin Program.
import spss, glob, spssaux
savlist=glob.glob('c:/path/proj_test/tst*.sav')
for basefile in savlist:
        outfile='nu'+ basefile
        spssaux.OpenDataFile(basefile)
        spss.Submit("""compute test=10*var_1.
        save outfile='c:/path/proj_test/outfile'
/compressed.""")
End Program.

Thanks in Advance

Mike




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of John Norton
Sent: Monday, July 24, 2006 4:03 PM
To: [hidden email]
Subject: Re: Make bold or in color sign. correlations in output

Hi List:

I wanted to add a caveat (or a "gotcha") to James Parry's reference to the 'Correlations_Table_Correlations_Create' script.  This is quite a useful script, but when running correlations from command language and using the WITH statement, this script will still remove the diagonal and the upper half of the matrix, regardless of the WITH statement.

So, for example, if you execute correlations from the dialogs with variables q1 q2 and q3, you'll get a matrix with variables q1 q2 and q3 defining both the rows and the columns.  So, in the diagonal, you'll get perfect correlations - as variables tend to do with themselves - and in the upper right corner half of the table you'll get identical correlations as you would with the variable combinations in the lower left half of the matrix.  In this case, it makes sense that the diagonals of correlations of variables with themselves, and the redundant upper corner half of the matrix be removed.

But if you use command language with the WITH statement:

CORRELATIONS
  /VARIABLES=x1 x2 x3 WITH x4 x5 x6
  /PRINT=TWOTAIL NOSIG
  /MISSING=PAIRWISE .

..you'll get a matrix with variables x1 x2 and x3 defining the rows and variables x4 x5 and x6 defining the columns.  The script will still remove the diagonal and the upper right corner half of the matrix, regardless of the fact that in this case, there are no redundancies.

This is more of an annoyance and a speed bump than anything else (especially if/when attempting to demonstrate correlations in class, and after forgetting that you've already demonstrated this script and left it active).  Still, it's a "gotcha" to be aware of - it's always a good idea to monitor what you automate.  :-)

Best,

John Norton
Biostatistician
Oncology Institute
Loyola University Medical Center

(708) 327-3095
[hidden email]

"Absence of evidence
      is not evidence of absence"


>>> "Parry, James" <[hidden email]> 7/24/2006 2:15 PM >>>

Hi Martin (and list!),

There is a script that comes with SPSS called 'Correlations_Table_Correlations_Create' that 1) omits the top part of the diagonal of the correlation matrix and b) highlights in yellow any significant correlations (to .01, 2-tailed).

The way to activate the autoscript is to go to Edit...Options, choose the Scripts Tab and make sure to select the second script down 'Correlations_Table_Correlations_Create'. After selecting the script, make sure to press OK, and then run correlations.

Also, if you're interested in altering any of the parameters (say significance level to be highlighted, color of highlighting or font, etc.), or if you want to make the script work for Spearman's, here is a link to an earlier, detailed explanation by one of SPSS' Statisticians:

http://www.listserv.uga.edu/cgi-bin/wa?A2=ind9811&L=spssx-l&P=2898

If anyone happens to have a version of this script in another language (Python, VB, etc.) please feel free to submit it to:
http://www.spss.com/devcentral/, our new meeting place for SPSS'ers interested in powerful statistical development.


Best,

James E. Parry
Systems Engineer, SPSS
Reply | Threaded
Open this post in threaded view
|

Re: Saving file as part of python program

Bauer, John H.
In reply to this post by Roberts, Michael
Robert,

Sorry I don't have time to explain the changes, the main point is that you weren't substituting outfile into the syntax.  Also note that glob1 searches on path, pattern making it easier to work with the results for your purposes.  Try something more like this:

Begin Program.
import spss, glob, spssaux
path = 'c:/temp/'
pattern = '*.sav'
savlist=glob.glob1(path, pattern)
for basefile in savlist:
        outfile=path + 'nu' + basefile
        spssaux.OpenDataFile(path + basefile)
        spss.Submit("""compute test=10 .
        save outfile='%s'
/compressed.""" % outfile)
End Program.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Roberts, Michael
Sent: Monday, July 24, 2006 3:29 PM
To: [hidden email]
Subject: Saving file as part of python program

Hi all,

Would someone be able to look at this code and let me know what is wrong?  I have tried several approaches, and although the files opened up, the code apparently works only on the last file opened, and then does not save it.

I selected a small sample of 5 spss formatted files in a folder to test the program, which is supposed to open the files one by one, perform an spss function - in this case, select the first ten cases, then save the file with the 'nu' in front of the old file name.

I would appreciate any help you can provide with this, as none of the documentation seems to address how to do this cyclical processing.


set printback on mprint on.
Begin Program.
import spss, glob, spssaux
savlist=glob.glob('c:/path/proj_test/tst*.sav')
for basefile in savlist:
        outfile='nu'+ basefile
        spssaux.OpenDataFile(basefile)
        spss.Submit("""compute test=10*var_1.
        save outfile='c:/path/proj_test/outfile'
/compressed.""")
End Program.

Thanks in Advance

Mike




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of John Norton
Sent: Monday, July 24, 2006 4:03 PM
To: [hidden email]
Subject: Re: Make bold or in color sign. correlations in output

Hi List:

I wanted to add a caveat (or a "gotcha") to James Parry's reference to the 'Correlations_Table_Correlations_Create' script.  This is quite a useful script, but when running correlations from command language and using the WITH statement, this script will still remove the diagonal and the upper half of the matrix, regardless of the WITH statement.

So, for example, if you execute correlations from the dialogs with variables q1 q2 and q3, you'll get a matrix with variables q1 q2 and q3 defining both the rows and the columns.  So, in the diagonal, you'll get perfect correlations - as variables tend to do with themselves - and in the upper right corner half of the table you'll get identical correlations as you would with the variable combinations in the lower left half of the matrix.  In this case, it makes sense that the diagonals of correlations of variables with themselves, and the redundant upper corner half of the matrix be removed.

But if you use command language with the WITH statement:

CORRELATIONS
  /VARIABLES=x1 x2 x3 WITH x4 x5 x6
  /PRINT=TWOTAIL NOSIG
  /MISSING=PAIRWISE .

..you'll get a matrix with variables x1 x2 and x3 defining the rows and variables x4 x5 and x6 defining the columns.  The script will still remove the diagonal and the upper right corner half of the matrix, regardless of the fact that in this case, there are no redundancies.

This is more of an annoyance and a speed bump than anything else (especially if/when attempting to demonstrate correlations in class, and after forgetting that you've already demonstrated this script and left it active).  Still, it's a "gotcha" to be aware of - it's always a good idea to monitor what you automate.  :-)

Best,

John Norton
Biostatistician
Oncology Institute
Loyola University Medical Center

(708) 327-3095
[hidden email]

"Absence of evidence
      is not evidence of absence"


>>> "Parry, James" <[hidden email]> 7/24/2006 2:15 PM >>>

Hi Martin (and list!),

There is a script that comes with SPSS called 'Correlations_Table_Correlations_Create' that 1) omits the top part of the diagonal of the correlation matrix and b) highlights in yellow any significant correlations (to .01, 2-tailed).

The way to activate the autoscript is to go to Edit...Options, choose the Scripts Tab and make sure to select the second script down 'Correlations_Table_Correlations_Create'. After selecting the script, make sure to press OK, and then run correlations.

Also, if you're interested in altering any of the parameters (say significance level to be highlighted, color of highlighting or font, etc.), or if you want to make the script work for Spearman's, here is a link to an earlier, detailed explanation by one of SPSS' Statisticians:

http://www.listserv.uga.edu/cgi-bin/wa?A2=ind9811&L=spssx-l&P=2898

If anyone happens to have a version of this script in another language (Python, VB, etc.) please feel free to submit it to:
http://www.spss.com/devcentral/, our new meeting place for SPSS'ers interested in powerful statistical development.


Best,

James E. Parry
Systems Engineer, SPSS
Reply | Threaded
Open this post in threaded view
|

Re: Saving file as part of python program

Roberts, Michael
John, and every one else who responded:

Thank you!!!  The changes you suggested works.  I had been going over
this over the entire weekend - poring through the Python manual,
integration plug in, and anything else I can get my hands on, without
too much success!

Mike




-----Original Message-----
From: Bauer, John H. [mailto:[hidden email]]
Sent: Monday, July 24, 2006 5:45 PM
To: Roberts, Michael; [hidden email]
Subject: RE: Saving file as part of python program

Robert,

Sorry I don't have time to explain the changes, the main point is that
you weren't substituting outfile into the syntax.  Also note that glob1
searches on path, pattern making it easier to work with the results for
your purposes.  Try something more like this:

Begin Program.
import spss, glob, spssaux
path = 'c:/temp/'
pattern = '*.sav'
savlist=glob.glob1(path, pattern)
for basefile in savlist:
        outfile=path + 'nu' + basefile
        spssaux.OpenDataFile(path + basefile)
        spss.Submit("""compute test=10 .
        save outfile='%s'
/compressed.""" % outfile)
End Program.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Roberts, Michael
Sent: Monday, July 24, 2006 3:29 PM
To: [hidden email]
Subject: Saving file as part of python program

Hi all,

Would someone be able to look at this code and let me know what is
wrong?  I have tried several approaches, and although the files opened
up, the code apparently works only on the last file opened, and then
does not save it.

I selected a small sample of 5 spss formatted files in a folder to test
the program, which is supposed to open the files one by one, perform an
spss function - in this case, select the first ten cases, then save the
file with the 'nu' in front of the old file name.

I would appreciate any help you can provide with this, as none of the
documentation seems to address how to do this cyclical processing.


set printback on mprint on.
Begin Program.
import spss, glob, spssaux
savlist=glob.glob('c:/path/proj_test/tst*.sav')
for basefile in savlist:
        outfile='nu'+ basefile
        spssaux.OpenDataFile(basefile)
        spss.Submit("""compute test=10*var_1.
        save outfile='c:/path/proj_test/outfile'
/compressed.""")
End Program.

Thanks in Advance

Mike




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
John Norton
Sent: Monday, July 24, 2006 4:03 PM
To: [hidden email]
Subject: Re: Make bold or in color sign. correlations in output

Hi List:

I wanted to add a caveat (or a "gotcha") to James Parry's reference to
the 'Correlations_Table_Correlations_Create' script.  This is quite a
useful script, but when running correlations from command language and
using the WITH statement, this script will still remove the diagonal and
the upper half of the matrix, regardless of the WITH statement.

So, for example, if you execute correlations from the dialogs with
variables q1 q2 and q3, you'll get a matrix with variables q1 q2 and q3
defining both the rows and the columns.  So, in the diagonal, you'll get
perfect correlations - as variables tend to do with themselves - and in
the upper right corner half of the table you'll get identical
correlations as you would with the variable combinations in the lower
left half of the matrix.  In this case, it makes sense that the
diagonals of correlations of variables with themselves, and the
redundant upper corner half of the matrix be removed.

But if you use command language with the WITH statement:

CORRELATIONS
  /VARIABLES=x1 x2 x3 WITH x4 x5 x6
  /PRINT=TWOTAIL NOSIG
  /MISSING=PAIRWISE .

..you'll get a matrix with variables x1 x2 and x3 defining the rows and
variables x4 x5 and x6 defining the columns.  The script will still
remove the diagonal and the upper right corner half of the matrix,
regardless of the fact that in this case, there are no redundancies.

This is more of an annoyance and a speed bump than anything else
(especially if/when attempting to demonstrate correlations in class, and
after forgetting that you've already demonstrated this script and left
it active).  Still, it's a "gotcha" to be aware of - it's always a good
idea to monitor what you automate.  :-)

Best,

John Norton
Biostatistician
Oncology Institute
Loyola University Medical Center

(708) 327-3095
[hidden email]

"Absence of evidence
      is not evidence of absence"


>>> "Parry, James" <[hidden email]> 7/24/2006 2:15 PM >>>

Hi Martin (and list!),

There is a script that comes with SPSS called
'Correlations_Table_Correlations_Create' that 1) omits the top part of
the diagonal of the correlation matrix and b) highlights in yellow any
significant correlations (to .01, 2-tailed).

The way to activate the autoscript is to go to Edit...Options, choose
the Scripts Tab and make sure to select the second script down
'Correlations_Table_Correlations_Create'. After selecting the script,
make sure to press OK, and then run correlations.

Also, if you're interested in altering any of the parameters (say
significance level to be highlighted, color of highlighting or font,
etc.), or if you want to make the script work for Spearman's, here is a
link to an earlier, detailed explanation by one of SPSS' Statisticians:

http://www.listserv.uga.edu/cgi-bin/wa?A2=ind9811&L=spssx-l&P=2898

If anyone happens to have a version of this script in another language
(Python, VB, etc.) please feel free to submit it to:
http://www.spss.com/devcentral/, our new meeting place for SPSS'ers
interested in powerful statistical development.


Best,

James E. Parry
Systems Engineer, SPSS
Reply | Threaded
Open this post in threaded view
|

Re: Saving file as part of python program

Hearne, Marcus
In reply to this post by Roberts, Michael
Greetings,

This thread has been cross-posted by John Bauer to the SPSS Developer Forums at SPSS Developer Central (http://www.spss.com/devcentral/). It can be found in the Python discussion forum under the topic "Open all files matching a pattern, save with new name".

This will allow users of SPSS Developer Central to more easily locate and benefit from the solution, and contribute alternatives.

We hope that the forums there will become the first stop for those using Python and SPSS Programmability, allowing the X-list to return to its regularly scheduled content. SPSS Developer Central has many benefits including input directly from the SPSS Programmability team and detailed solutions including sample code.

Regards,
Marcus Hearne
Sr. Product Manager
SPSS Inc.




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bauer, John H.
Sent: Monday, July 24, 2006 4:45 PM
To: [hidden email]
Subject: Re: Saving file as part of python program

Robert,

Sorry I don't have time to explain the changes, the main point is that you weren't substituting outfile into the syntax.  Also note that glob1 searches on path, pattern making it easier to work with the results for your purposes.  Try something more like this:

Begin Program.
import spss, glob, spssaux
path = 'c:/temp/'
pattern = '*.sav'
savlist=glob.glob1(path, pattern)
for basefile in savlist:
        outfile=path + 'nu' + basefile
        spssaux.OpenDataFile(path + basefile)
        spss.Submit("""compute test=10 .
        save outfile='%s'
/compressed.""" % outfile)
End Program.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Roberts, Michael
Sent: Monday, July 24, 2006 3:29 PM
To: [hidden email]
Subject: Saving file as part of python program

Hi all,

Would someone be able to look at this code and let me know what is wrong?  I have tried several approaches, and although the files opened up, the code apparently works only on the last file opened, and then does not save it.

I selected a small sample of 5 spss formatted files in a folder to test the program, which is supposed to open the files one by one, perform an spss function - in this case, select the first ten cases, then save the file with the 'nu' in front of the old file name.

I would appreciate any help you can provide with this, as none of the documentation seems to address how to do this cyclical processing.


set printback on mprint on.
Begin Program.
import spss, glob, spssaux
savlist=glob.glob('c:/path/proj_test/tst*.sav')
for basefile in savlist:
        outfile='nu'+ basefile
        spssaux.OpenDataFile(basefile)
        spss.Submit("""compute test=10*var_1.
        save outfile='c:/path/proj_test/outfile'
/compressed.""")
End Program.

Thanks in Advance

Mike




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of John Norton
Sent: Monday, July 24, 2006 4:03 PM
To: [hidden email]
Subject: Re: Make bold or in color sign. correlations in output

Hi List:

I wanted to add a caveat (or a "gotcha") to James Parry's reference to the 'Correlations_Table_Correlations_Create' script.  This is quite a useful script, but when running correlations from command language and using the WITH statement, this script will still remove the diagonal and the upper half of the matrix, regardless of the WITH statement.

So, for example, if you execute correlations from the dialogs with variables q1 q2 and q3, you'll get a matrix with variables q1 q2 and q3 defining both the rows and the columns.  So, in the diagonal, you'll get perfect correlations - as variables tend to do with themselves - and in the upper right corner half of the table you'll get identical correlations as you would with the variable combinations in the lower left half of the matrix.  In this case, it makes sense that the diagonals of correlations of variables with themselves, and the redundant upper corner half of the matrix be removed.

But if you use command language with the WITH statement:

CORRELATIONS
  /VARIABLES=x1 x2 x3 WITH x4 x5 x6
  /PRINT=TWOTAIL NOSIG
  /MISSING=PAIRWISE .

..you'll get a matrix with variables x1 x2 and x3 defining the rows and variables x4 x5 and x6 defining the columns.  The script will still remove the diagonal and the upper right corner half of the matrix, regardless of the fact that in this case, there are no redundancies.

This is more of an annoyance and a speed bump than anything else (especially if/when attempting to demonstrate correlations in class, and after forgetting that you've already demonstrated this script and left it active).  Still, it's a "gotcha" to be aware of - it's always a good idea to monitor what you automate.  :-)

Best,

John Norton
Biostatistician
Oncology Institute
Loyola University Medical Center

(708) 327-3095
[hidden email]

"Absence of evidence
      is not evidence of absence"


>>> "Parry, James" <[hidden email]> 7/24/2006 2:15 PM >>>

Hi Martin (and list!),

There is a script that comes with SPSS called 'Correlations_Table_Correlations_Create' that 1) omits the top part of the diagonal of the correlation matrix and b) highlights in yellow any significant correlations (to .01, 2-tailed).

The way to activate the autoscript is to go to Edit...Options, choose the Scripts Tab and make sure to select the second script down 'Correlations_Table_Correlations_Create'. After selecting the script, make sure to press OK, and then run correlations.

Also, if you're interested in altering any of the parameters (say significance level to be highlighted, color of highlighting or font, etc.), or if you want to make the script work for Spearman's, here is a link to an earlier, detailed explanation by one of SPSS' Statisticians:

http://www.listserv.uga.edu/cgi-bin/wa?A2=ind9811&L=spssx-l&P=2898

If anyone happens to have a version of this script in another language (Python, VB, etc.) please feel free to submit it to:
http://www.spss.com/devcentral/, our new meeting place for SPSS'ers interested in powerful statistical development.


Best,

James E. Parry
Systems Engineer, SPSS
Reply | Threaded
Open this post in threaded view
|

Discriminant Analysis Obtaining Combined Groups Plot

Dr. G. Steube, CCP
In reply to this post by Parry, James
 Hi!

I am running a Discriminant Analysis (SPSS 14).  I am trying to obtain a
combined groups plot to show the classifications for my two groups.  In the
output viewer window I have the following message:

Warnings
All-Groups Stacked Histogram is no longer displayed.

I tried redoing the analysis but the same message occurs.  How can I obtain
a combined group plot to illustrate the classification for the two groups?
Thanks.


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.10.7/411 - Release Date: 8/7/2006