|
Hi Sibusiyo
Tuesday, August 29, 2006, 11:13:00 PM, You wrote: SM> Well I have two series of numeric data which I was hoping are SM> similar/highly correlated/the same so I could use them SM> interchangeably in my analysis. First of all, high correlation doesn't mean "similar" or "the same". The second series values might duplicate the first series (clearly, quite a difference) but still the correlation might be very high. You can use Lin's CCC (Concordance Correlation Coefficient), a type of correlation coefficient that penalizes the departure of the series from the equality line (I have code for it, or you can use "Pairsetc.exe", part of WinPepi, a freeware statistical package: http://www.brixtonhealth.com/pepi4windows.html ). You could also try Bland-Altman analysis. Basically, you plot the differences (y axis) against the average of the two values (x axis) and take a look at the patterns (for instance: is the difference independent of the mean values or is it correlated in some way?). You can get a lot of information from the graph. Again, I have some code (or you can try a demo of MedCalc http://www.medcalc.be/download.php ) -- Regards, Dr. Marta García-Granero,PhD mailto:[hidden email] Statistician --- "It is unwise to use a statistical procedure whose use one does not understand. SPSS syntax guide cannot supply this knowledge, and it is certainly no substitute for the basic understanding of statistics and statistical thinking that is essential for the wise choice of methods and the correct interpretation of their results". (Adapted from WinPepi manual - I'm sure Joe Abrahmson will not mind) |
|
In reply to this post by Sibusiso Moyo
Dear ALL,
I have 10 products that I have been tracking for the past 60 months. So for each product I want to create a date variable that counts month 1 to month 60. I then want this repeated for products 2 to 10. I'd like to creat a date variable of the following format. I have a start date 08/01/2001 for case 1. Now for cases 2 up to 60 I want the date variable to add an additional month, so I could move from 08/01/2001 to 09/01/2001 etc until the 60th month which is 07/01/2006. Adios, Sibusiso. |
|
see if the date command will do what you want
________________________________ From: SPSSX(r) Discussion on behalf of Sibusiso Moyo Sent: Wed 8/30/2006 9:32 AM To: [hidden email] Subject: Re: Creating a date variable Dear ALL, I have 10 products that I have been tracking for the past 60 months. So for each product I want to create a date variable that counts month 1 to month 60. I then want this repeated for products 2 to 10. I'd like to creat a date variable of the following format. I have a start date 08/01/2001 for case 1. Now for cases 2 up to 60 I want the date variable to add an additional month, so I could move from 08/01/2001 to 09/01/2001 etc until the 60th month which is 07/01/2006. Adios, Sibusiso. |
|
In reply to this post by Sibusiso Moyo
Subusiso,
Here is one way to do this. The idea is to increment the months and years in separate variables and then put them together. Days looks to be fixed to a value of 1. So that is a constant. I'll assume your cases are sorted in the correct order so that the case number is the month counter. Compute mo1a=8+$casenum-1. /* this your starting month. Compute mo1b=mod((mo1a-1),12)+1. Compute yr1a=2001+trunc((mo1a-1)/12). Compute date1=date.mdy(mo1b,1,yr1a). Since you have multiple ones of these to do, you could use a Do repeat structure. The key element in that setup is that numbers and characters as well as variables can be used in the list of elements. Gene Maguin |
|
In reply to this post by Sibusiso Moyo
Thanks to ViAnn, I turned to the DATE Function in SPSS and it worked. I split my file by ID1 then allowed the date function to do its magic. Thanks again!
*** Split file SORT CASES BY ID1 . SPLIT FILE SEPARATE BY ID1 . The following new variables are being created: Name Label YEAR_ YEAR, not periodic MONTH_ MONTH, period 12 DATE_ Date. Format: "MMM YYYY" Rename variables DATE_ = MONTH. EXE. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Gene Maguin Sent: Wednesday, August 30, 2006 11:02 AM To: [hidden email] Subject: Re: Creating a date variable Subusiso, Here is one way to do this. The idea is to increment the months and years in separate variables and then put them together. Days looks to be fixed to a value of 1. So that is a constant. I'll assume your cases are sorted in the correct order so that the case number is the month counter. Compute mo1a=8+$casenum-1. /* this your starting month. Compute mo1b=mod((mo1a-1),12)+1. Compute yr1a=2001+trunc((mo1a-1)/12). Compute date1=date.mdy(mo1b,1,yr1a). Since you have multiple ones of these to do, you could use a Do repeat structure. The key element in that setup is that numbers and characters as well as variables can be used in the list of elements. Gene Maguin |
|
In reply to this post by Sibusiso Moyo
Dear All,
I use SPSS 14 everyday, and I must admit that I am tired of writting un-intelligent codes. So I am trying to learn programming in SPSS macros. Any suggestions in terms of what material I should look at for examples for a beginner? I currently have the 2003 version of SPSS Programming and Data Management by Ray Levesque. Sibusiso. |
|
Hi Sibusiso
SM> I use SPSS 14 everyday, and I must admit that I am tired of SM> writting un-intelligent codes. So I am trying to learn programming SM> in SPSS macros. Wellcome to the club. SM> Any suggestions in terms of what material I should SM> look at for examples for a beginner? The Command Syntax Reference is quite useful, at least, it's what I used when I started programming macros. The DEFINE-!ENDDEFINE chapter has a lot of examples, starting with very simple MACROs. There is also another Chapter at the end: Using the MACRO facility with 3 examples explained step by step. Take also a look at the MACRO section of Ray's website: http://www.spsstools.net/Macros.htm SM> I currently have the 2003 version of SPSS Programming and SM> Data Management by Ray Levesque. Since you are using SPSS 14, if you want to learn how to use the Programmability Extension, you should download the 3rd Edition of the book http://www.spss.com/spss/data_management_book.htm If you want to learn, for the moment, only "classic" macro programming, then the 2003 edition of the book is OK. -- Regards, Marta |
|
In reply to this post by Sibusiso Moyo
Once again your advice is appreciated,
Thanks! -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Marta García-Granero Sent: Thursday, August 31, 2006 5:42 AM To: [hidden email] Subject: Re: Learning to program in SPSS macros Hi Sibusiso SM> I use SPSS 14 everyday, and I must admit that I am tired of SM> writting un-intelligent codes. So I am trying to learn programming SM> in SPSS macros. Wellcome to the club. SM> Any suggestions in terms of what material I should SM> look at for examples for a beginner? The Command Syntax Reference is quite useful, at least, it's what I used when I started programming macros. The DEFINE-!ENDDEFINE chapter has a lot of examples, starting with very simple MACROs. There is also another Chapter at the end: Using the MACRO facility with 3 examples explained step by step. Take also a look at the MACRO section of Ray's website: http://www.spsstools.net/Macros.htm SM> I currently have the 2003 version of SPSS Programming and SM> Data Management by Ray Levesque. Since you are using SPSS 14, if you want to learn how to use the Programmability Extension, you should download the 3rd Edition of the book http://www.spss.com/spss/data_management_book.htm If you want to learn, for the moment, only "classic" macro programming, then the 2003 edition of the book is OK. -- Regards, Marta |
|
Hello all,
I agree with all of the advice given already. I would simply add to that the advice that you can visit, http://www.spss.com/devcentral/ This would be a good place to visit to determine if the "classic" approach would suffice. Certain aspects of macros will be trumped by the newer choices offered in 14.0., referred to as "programmability" (discussed only in the 3rd edition). That vague term is used because as of 14.0 external programming languages can be used, but there are choices as to which one. As of the summer of this year, the two choices are Python and VB.net. There hasn't been tremendous traffic on the list serve regarding this yet, but it is bound to pick up since it has been announced that 15.0 will have python on the SPSS installation disk (or you can visit www.python.org and download it for free). There are also "scripts" to consider. Investing a couple of hours understanding you options, would be well worth it, although the wealth of choices can seem a mixed blessing. If time permits, consider the SPSS course that overviews all of the programming options including macros, scripts, and python. http://www.spss.com/training/pub_desc.cfm?courseID=100000436 I should note that I am aware of the course because I have taught it, but I consider it a good investment of two days. Good luck. best, Keith www.keithmccormick.com On 8/31/06, Sibusiso Moyo <[hidden email]> wrote: > Once again your advice is appreciated, > > Thanks! > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of > Marta García-Granero > Sent: Thursday, August 31, 2006 5:42 AM > To: [hidden email] > Subject: Re: Learning to program in SPSS macros > > > Hi Sibusiso > > SM> I use SPSS 14 everyday, and I must admit that I am tired of > SM> writting un-intelligent codes. So I am trying to learn programming > SM> in SPSS macros. > > Wellcome to the club. > > SM> Any suggestions in terms of what material I should > SM> look at for examples for a beginner? > > The Command Syntax Reference is quite useful, at least, it's what I > used when I started programming macros. The DEFINE-!ENDDEFINE chapter > has a lot of examples, starting with very simple MACROs. There is also > another Chapter at the end: Using the MACRO facility with 3 examples > explained step by step. > > Take also a look at the MACRO section of Ray's website: > > http://www.spsstools.net/Macros.htm > > SM> I currently have the 2003 version of SPSS Programming and > SM> Data Management by Ray Levesque. > > Since you are using SPSS 14, if you want to learn how to use the > Programmability Extension, you should download the 3rd Edition of the > book > > http://www.spss.com/spss/data_management_book.htm > > If you want to learn, for the moment, only "classic" macro > programming, then the 2003 edition of the book is OK. > > > -- > Regards, > Marta > |
|
In reply to this post by Sibusiso Moyo
Hi Sibusiso,
Have you considered using the "Visual Bander" on the difference? You could take the difference and explore which cases were outside +- 3 sd on the difference. The standard deviation is easy to calculate using Analyze ... Descriptive Statistics ..Descriptives. The Visual Bander is found under Transform ... Visual Binning .... You can make cutpoints at +- 3z (you don't need descriptive to do this), and thereby divide your differences variable into three groups: quite low, medium, and quite high. Hope that helps, Keith www.keithmccormick.com On 8/29/06, Sibusiso Moyo <[hidden email]> wrote: > Dear All, > > I have about 13000 cases in my data set. I have these two variables that I am trying to test how close they are from each other. Specifically I am trying to identify cases, where the biggest difference arises. Besides taking differences between the two, sorting the data by the resulting difference variable, plots etc, would anyone have any ideas how one would proceed with such an assignment. > > Thanks, > > Sibusiso. > |
|
In reply to this post by Sibusiso Moyo
Thanks for information Keith. I don't consider myself a programmer (am not proficient enough), although I must admit that I find programming very attractive as a past time. So besides learning the macros, I will be trying the Python extension. It looks very useful.
Sibusiso. -----Original Message----- From: Keith McCormick [mailto:[hidden email]] Sent: Monday, September 04, 2006 12:57 PM To: Sibusiso Moyo Cc: [hidden email] Subject: Re: Learning to program in SPSS macros Hello all, I agree with all of the advice given already. I would simply add to that the advice that you can visit, http://www.spss.com/devcentral/ This would be a good place to visit to determine if the "classic" approach would suffice. Certain aspects of macros will be trumped by the newer choices offered in 14.0., referred to as "programmability" (discussed only in the 3rd edition). That vague term is used because as of 14.0 external programming languages can be used, but there are choices as to which one. As of the summer of this year, the two choices are Python and VB.net. There hasn't been tremendous traffic on the list serve regarding this yet, but it is bound to pick up since it has been announced that 15.0 will have python on the SPSS installation disk (or you can visit www.python.org and download it for free). There are also "scripts" to consider. Investing a couple of hours understanding you options, would be well worth it, although the wealth of choices can seem a mixed blessing. If time permits, consider the SPSS course that overviews all of the programming options including macros, scripts, and python. http://www.spss.com/training/pub_desc.cfm?courseID=100000436 I should note that I am aware of the course because I have taught it, but I consider it a good investment of two days. Good luck. best, Keith www.keithmccormick.com On 8/31/06, Sibusiso Moyo <[hidden email]> wrote: > Once again your advice is appreciated, > > Thanks! > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of > Marta García-Granero > Sent: Thursday, August 31, 2006 5:42 AM > To: [hidden email] > Subject: Re: Learning to program in SPSS macros > > > Hi Sibusiso > > SM> I use SPSS 14 everyday, and I must admit that I am tired of > SM> writting un-intelligent codes. So I am trying to learn programming > SM> in SPSS macros. > > Wellcome to the club. > > SM> Any suggestions in terms of what material I should > SM> look at for examples for a beginner? > > The Command Syntax Reference is quite useful, at least, it's what I > used when I started programming macros. The DEFINE-!ENDDEFINE chapter > has a lot of examples, starting with very simple MACROs. There is also > another Chapter at the end: Using the MACRO facility with 3 examples > explained step by step. > > Take also a look at the MACRO section of Ray's website: > > http://www.spsstools.net/Macros.htm > > SM> I currently have the 2003 version of SPSS Programming and > SM> Data Management by Ray Levesque. > > Since you are using SPSS 14, if you want to learn how to use the > Programmability Extension, you should download the 3rd Edition of the > book > > http://www.spss.com/spss/data_management_book.htm > > If you want to learn, for the moment, only "classic" macro > programming, then the 2003 edition of the book is OK. > > > -- > Regards, > Marta > |
|
In reply to this post by Sibusiso Moyo
Keith,
As a follow up question. How compatible is Python to SPSS? Can all the stuff that I do on SPSS be transferred to Python? Which is one more user friendly (in my company people like things simple :))? Can the Python code be easity re-integrated to SPSS syntax? Sibusiso. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Keith McCormick Sent: Monday, September 04, 2006 12:57 PM To: [hidden email] Subject: Re: Learning to program in SPSS macros Hello all, I agree with all of the advice given already. I would simply add to that the advice that you can visit, http://www.spss.com/devcentral/ This would be a good place to visit to determine if the "classic" approach would suffice. Certain aspects of macros will be trumped by the newer choices offered in 14.0., referred to as "programmability" (discussed only in the 3rd edition). That vague term is used because as of 14.0 external programming languages can be used, but there are choices as to which one. As of the summer of this year, the two choices are Python and VB.net. There hasn't been tremendous traffic on the list serve regarding this yet, but it is bound to pick up since it has been announced that 15.0 will have python on the SPSS installation disk (or you can visit www.python.org and download it for free). There are also "scripts" to consider. Investing a couple of hours understanding you options, would be well worth it, although the wealth of choices can seem a mixed blessing. If time permits, consider the SPSS course that overviews all of the programming options including macros, scripts, and python. http://www.spss.com/training/pub_desc.cfm?courseID=100000436 I should note that I am aware of the course because I have taught it, but I consider it a good investment of two days. Good luck. best, Keith www.keithmccormick.com On 8/31/06, Sibusiso Moyo <[hidden email]> wrote: > Once again your advice is appreciated, > > Thanks! > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of > Marta García-Granero > Sent: Thursday, August 31, 2006 5:42 AM > To: [hidden email] > Subject: Re: Learning to program in SPSS macros > > > Hi Sibusiso > > SM> I use SPSS 14 everyday, and I must admit that I am tired of > SM> writting un-intelligent codes. So I am trying to learn programming > SM> in SPSS macros. > > Wellcome to the club. > > SM> Any suggestions in terms of what material I should > SM> look at for examples for a beginner? > > The Command Syntax Reference is quite useful, at least, it's what I > used when I started programming macros. The DEFINE-!ENDDEFINE chapter > has a lot of examples, starting with very simple MACROs. There is also > another Chapter at the end: Using the MACRO facility with 3 examples > explained step by step. > > Take also a look at the MACRO section of Ray's website: > > http://www.spsstools.net/Macros.htm > > SM> I currently have the 2003 version of SPSS Programming and > SM> Data Management by Ray Levesque. > > Since you are using SPSS 14, if you want to learn how to use the > Programmability Extension, you should download the 3rd Edition of the > book > > http://www.spss.com/spss/data_management_book.htm > > If you want to learn, for the moment, only "classic" macro > programming, then the 2003 edition of the book is OK. > > > -- > Regards, > Marta > |
|
At 05:44 PM 9/5/2006, Sibusiso Moyo wrote:
>As a follow up question. How compatible is Python to SPSS? Can all the >stuff that I do on SPSS be transferred to Python? Which is one more >user friendly (in my company people like things simple :))? Can the >Python code be easity re-integrated to SPSS syntax? The short answer is, they're entirely different languages; in that sense, not compatible at all. Nothing written to run in SPSS can run in Python, or vice versa. Python can create and submit SPSS statements that are then executed. For how that's done; and for how different the syntaxes look; see my just-now posting "Re: Renaming variables - noncontinuous", or various postings by Jon Peck of SPSS, Inc. It's being suggested that SPSS syntax be replaced with Python entirely; that is, SPSS code will only be generated by Python programs, which will use their own functions so that the users see none of the SPSS code. For advocacy of that, see Jon Peck; for myself, I'm doubtful, for anything like the near future. Among other things, it means a very careful set of Python functions; and it means discarding much of the skill of current SPSS programmers. For more details, from a 'pro' point of view, see http://www.spss.com/devcentral/files/articles/convert_spss_to_python1.pdf |
|
It is true that Python and SPSS syntax are different languages, but it is very powerful to use Python to generate SPSS commands as well as using the direct functionality of Python function calls to SPSS.
But I'd like to clarify the "It's being suggested comment below". There is no intention of replacing SPSS syntax with Python syntax entirely if that is taken to mean that SPSS syntax would no longer be available. What is interesting is the possibility of providing a pure Python set of objects that would allow a Python programmer to write object-oriented code that would generate and submit SPSS syntax underneath. For example, you can open a data file and assign a dataset name to it with SPSS syntax like this. GET FILE='filespec'. DATASET NAME mydataset. Nothing wrong with that. But you could also accomplish this in a BEGIN PROGRAM block with spssaux.OpenDataFile('filespec', dataset='mydataset') In similar ways you can wrap more complex SPSS syntax in Python notation. The Transform module on Developer Central (www.spss.com/devcentral) allows you to do COMPUTE and DO IF commands along with VARIABLE LABEL, VARIABLE LEVEL, etc in o-o notation with something like this. This Python syntax defines all the metadata for a new variable, computes it conditionally, and as an extra, makes the data updatable in the future. newvar = Transform.Compute(varname="average_increase", varlabel="Salary increase per month of experience if at least a year",\ varmeaslvl="Scale",\ varmissval=[999,998,997],\ varformat="F8.4") newvar.expression = "(salary-salbegin)/jobtime" newvar.condition = "jobtime > 12" newvar.retransformable=True newvar.generate() # An exception will be raised if the compute fails The equivalent SPSS syntax (without the updatable variable) would be this. NUMERIC average_increase. FORMAT average_increase (F8.4). VARIABLE LABEL average_increase "Salary increase per month of experience if at least a year". VARIABLE LEVEL average_increase (Scale). MISSING VALUES average_increase (999,998, 997). DO IF jobtime > 12. COMPUTE average_increase = (salary-salbegin)/jobtime. END IF. So this approach turns SPSS syntax into a full fledged object-oriented programming language, but it leaves SPSS syntax underneath doing the work. And it certainly does not eliminate the powerful SPSS syntax, which will remain fully available. Not only is it widely known, there are zillions of existing jobs that will continue to run. And new SPSS syntax will continue to be created for new procedures. But if your style inclinations are towards object-oriented programming, the Python approach may appeal strongly. Someone, of course, would have to create the Python code to generate all that SPSS syntax, which is not happening now, at least within SPSS. So this is an idea that I like, but that's my personal opinion. Regards, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Richard Ristow Sent: Wednesday, September 06, 2006 12:01 AM To: [hidden email] Subject: Re: [SPSSX-L] Learning to program in SPSS macros At 05:44 PM 9/5/2006, Sibusiso Moyo wrote: >As a follow up question. How compatible is Python to SPSS? Can all the >stuff that I do on SPSS be transferred to Python? Which is one more >user friendly (in my company people like things simple :))? Can the >Python code be easity re-integrated to SPSS syntax? The short answer is, they're entirely different languages; in that sense, not compatible at all. Nothing written to run in SPSS can run in Python, or vice versa. Python can create and submit SPSS statements that are then executed. For how that's done; and for how different the syntaxes look; see my just-now posting "Re: Renaming variables - noncontinuous", or various postings by Jon Peck of SPSS, Inc. It's being suggested that SPSS syntax be replaced with Python entirely; that is, SPSS code will only be generated by Python programs, which will use their own functions so that the users see none of the SPSS code. For advocacy of that, see Jon Peck; for myself, I'm doubtful, for anything like the near future. Among other things, it means a very careful set of Python functions; and it means discarding much of the skill of current SPSS programmers. For more details, from a 'pro' point of view, see http://www.spss.com/devcentral/files/articles/convert_spss_to_python1.pdf |
|
In reply to this post by Sibusiso Moyo
Jon said:
"Someone, of course, would have to create the Python code to generate all that SPSS syntax, which is not happening now, at least within SPSS." Can you please tell us more about this? What % of transformation and basic proc commands are currently mapped to python methods/properties (e.g. could someone abandon SPSS code entirely now for simple things)? Will SPSS be completing this mapping for future releases? Thanks -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peck, Jon Sent: Wednesday, September 06, 2006 8:02 AM To: [hidden email] Subject: Re: Learning to program in SPSS macros It is true that Python and SPSS syntax are different languages, but it is very powerful to use Python to generate SPSS commands as well as using the direct functionality of Python function calls to SPSS. But I'd like to clarify the "It's being suggested comment below". There is no intention of replacing SPSS syntax with Python syntax entirely if that is taken to mean that SPSS syntax would no longer be available. What is interesting is the possibility of providing a pure Python set of objects that would allow a Python programmer to write object-oriented code that would generate and submit SPSS syntax underneath. For example, you can open a data file and assign a dataset name to it with SPSS syntax like this. GET FILE='filespec'. DATASET NAME mydataset. Nothing wrong with that. But you could also accomplish this in a BEGIN PROGRAM block with spssaux.OpenDataFile('filespec', dataset='mydataset') In similar ways you can wrap more complex SPSS syntax in Python notation. The Transform module on Developer Central (www.spss.com/devcentral) allows you to do COMPUTE and DO IF commands along with VARIABLE LABEL, VARIABLE LEVEL, etc in o-o notation with something like this. This Python syntax defines all the metadata for a new variable, computes it conditionally, and as an extra, makes the data updatable in the future. newvar = Transform.Compute(varname="average_increase", varlabel="Salary increase per month of experience if at least a year",\ varmeaslvl="Scale",\ varmissval=[999,998,997],\ varformat="F8.4") newvar.expression = "(salary-salbegin)/jobtime" newvar.condition = "jobtime > 12" newvar.retransformable=True newvar.generate() # An exception will be raised if the compute fails The equivalent SPSS syntax (without the updatable variable) would be this. NUMERIC average_increase. FORMAT average_increase (F8.4). VARIABLE LABEL average_increase "Salary increase per month of experience if at least a year". VARIABLE LEVEL average_increase (Scale). MISSING VALUES average_increase (999,998, 997). DO IF jobtime > 12. COMPUTE average_increase = (salary-salbegin)/jobtime. END IF. So this approach turns SPSS syntax into a full fledged object-oriented programming language, but it leaves SPSS syntax underneath doing the work. And it certainly does not eliminate the powerful SPSS syntax, which will remain fully available. Not only is it widely known, there are zillions of existing jobs that will continue to run. And new SPSS syntax will continue to be created for new procedures. But if your style inclinations are towards object-oriented programming, the Python approach may appeal strongly. Someone, of course, would have to create the Python code to generate all that SPSS syntax, which is not happening now, at least within SPSS. So this is an idea that I like, but that's my personal opinion. Regards, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Richard Ristow Sent: Wednesday, September 06, 2006 12:01 AM To: [hidden email] Subject: Re: [SPSSX-L] Learning to program in SPSS macros At 05:44 PM 9/5/2006, Sibusiso Moyo wrote: >As a follow up question. How compatible is Python to SPSS? Can all the >stuff that I do on SPSS be transferred to Python? Which is one more >user friendly (in my company people like things simple :))? Can the >Python code be easity re-integrated to SPSS syntax? The short answer is, they're entirely different languages; in that sense, not compatible at all. Nothing written to run in SPSS can run in Python, or vice versa. Python can create and submit SPSS statements that are then executed. For how that's done; and for how different the syntaxes look; see my just-now posting "Re: Renaming variables - noncontinuous", or various postings by Jon Peck of SPSS, Inc. It's being suggested that SPSS syntax be replaced with Python entirely; that is, SPSS code will only be generated by Python programs, which will use their own functions so that the users see none of the SPSS code. For advocacy of that, see Jon Peck; for myself, I'm doubtful, for anything like the near future. Among other things, it means a very careful set of Python functions; and it means discarding much of the skill of current SPSS programmers. For more details, from a 'pro' point of view, see http://www.spss.com/devcentral/files/articles/convert_spss_to_python1.pd f |
|
There is no official SPSS project at this point to "complete the mapping", but quite a lot has been done already, and the imminent SPSS 15 has further enhancements.
The Transform module that I described handles DO IF, COMPUTE, RECODE, and COUNT. These are the heavy duty transformation commands that do not have equivalents on the Python side. (None of this addresses INPUT PROGRAM). Something like, say, DO REPEAT, corresponds to iterating over a variable list, and this can already be written easily in Python code. In fact, the spssaux VariableDict class makes it easy to construct lists of variables by using any of lists of names, ranges (like TO but more general), filters on measurement level, type, etc, and wildcards on the names (every variable whose name includes AGE, for example). If you construct variable lists this way or in more basic ways, then something like a hyper DO REPEAT is easy, and the Python loops could include procedures, too. Now in SPSS 15, which is just being finalized now, there is another dramatic expansion in the ability to do SPSS transformations via Python. You can create new variables and assign properties, including the variable attributes introduced in SPSS 14 and values directly, so you can, in effect, do transformations in Python using any functions available or that you write that produce suitable casewise values. I have just finished implementing a Soundex function, for example, and several others. With SPSS 15, you can also append new cases. So I believe that it is quite feasible with SPSS 15 to write almost any transformations in pure Python code running in or on top of SPSS if you so desire. I will be talking about this in more detail at the SPSS Directions conference in Chicago in early November (see www.spss.com for details on the conference). Again let me emphasize that there is no plan to eliminate SPSS syntax or even an SPSS project to wrap everything in Python garb. And Python and the Plug-In are optional installs, so some users may not have access to these methods. HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bauer, Craig Sent: Wednesday, September 06, 2006 9:55 AM To: [hidden email] Subject: Re: [SPSSX-L] Learning to program in SPSS macros Jon said: "Someone, of course, would have to create the Python code to generate all that SPSS syntax, which is not happening now, at least within SPSS." Can you please tell us more about this? What % of transformation and basic proc commands are currently mapped to python methods/properties (e.g. could someone abandon SPSS code entirely now for simple things)? Will SPSS be completing this mapping for future releases? Thanks -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peck, Jon Sent: Wednesday, September 06, 2006 8:02 AM To: [hidden email] Subject: Re: Learning to program in SPSS macros It is true that Python and SPSS syntax are different languages, but it is very powerful to use Python to generate SPSS commands as well as using the direct functionality of Python function calls to SPSS. But I'd like to clarify the "It's being suggested comment below". There is no intention of replacing SPSS syntax with Python syntax entirely if that is taken to mean that SPSS syntax would no longer be available. What is interesting is the possibility of providing a pure Python set of objects that would allow a Python programmer to write object-oriented code that would generate and submit SPSS syntax underneath. For example, you can open a data file and assign a dataset name to it with SPSS syntax like this. GET FILE='filespec'. DATASET NAME mydataset. Nothing wrong with that. But you could also accomplish this in a BEGIN PROGRAM block with spssaux.OpenDataFile('filespec', dataset='mydataset') In similar ways you can wrap more complex SPSS syntax in Python notation. The Transform module on Developer Central (www.spss.com/devcentral) allows you to do COMPUTE and DO IF commands along with VARIABLE LABEL, VARIABLE LEVEL, etc in o-o notation with something like this. This Python syntax defines all the metadata for a new variable, computes it conditionally, and as an extra, makes the data updatable in the future. newvar = Transform.Compute(varname="average_increase", varlabel="Salary increase per month of experience if at least a year",\ varmeaslvl="Scale",\ varmissval=[999,998,997],\ varformat="F8.4") newvar.expression = "(salary-salbegin)/jobtime" newvar.condition = "jobtime > 12" newvar.retransformable=True newvar.generate() # An exception will be raised if the compute fails The equivalent SPSS syntax (without the updatable variable) would be this. NUMERIC average_increase. FORMAT average_increase (F8.4). VARIABLE LABEL average_increase "Salary increase per month of experience if at least a year". VARIABLE LEVEL average_increase (Scale). MISSING VALUES average_increase (999,998, 997). DO IF jobtime > 12. COMPUTE average_increase = (salary-salbegin)/jobtime. END IF. So this approach turns SPSS syntax into a full fledged object-oriented programming language, but it leaves SPSS syntax underneath doing the work. And it certainly does not eliminate the powerful SPSS syntax, which will remain fully available. Not only is it widely known, there are zillions of existing jobs that will continue to run. And new SPSS syntax will continue to be created for new procedures. But if your style inclinations are towards object-oriented programming, the Python approach may appeal strongly. Someone, of course, would have to create the Python code to generate all that SPSS syntax, which is not happening now, at least within SPSS. So this is an idea that I like, but that's my personal opinion. Regards, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Richard Ristow Sent: Wednesday, September 06, 2006 12:01 AM To: [hidden email] Subject: Re: [SPSSX-L] Learning to program in SPSS macros At 05:44 PM 9/5/2006, Sibusiso Moyo wrote: >As a follow up question. How compatible is Python to SPSS? Can all the >stuff that I do on SPSS be transferred to Python? Which is one more >user friendly (in my company people like things simple :))? Can the >Python code be easity re-integrated to SPSS syntax? The short answer is, they're entirely different languages; in that sense, not compatible at all. Nothing written to run in SPSS can run in Python, or vice versa. Python can create and submit SPSS statements that are then executed. For how that's done; and for how different the syntaxes look; see my just-now posting "Re: Renaming variables - noncontinuous", or various postings by Jon Peck of SPSS, Inc. It's being suggested that SPSS syntax be replaced with Python entirely; that is, SPSS code will only be generated by Python programs, which will use their own functions so that the users see none of the SPSS code. For advocacy of that, see Jon Peck; for myself, I'm doubtful, for anything like the near future. Among other things, it means a very careful set of Python functions; and it means discarding much of the skill of current SPSS programmers. For more details, from a 'pro' point of view, see http://www.spss.com/devcentral/files/articles/convert_spss_to_python1.pd f |
|
All,
I've run an ancova and found that I have IV by covariate interaction. I then did emmeans to locate the score at which the interaction became significant. So I can say that at at score of 4.35 or above group A differed from group B. What I'd like to do is turn that 4.35 into a percentile to give readers an idea of how far out in the distribution that 4.35 actually is. So I look at my distribution and I see that the cumulative percentage for a score of 4.3, which 103 people had, is 85.6% and the cum percentage for the next higher score, 4.5, is 91.6%. My question is how to state the percentile equivalent of 4.35 given the observed distribution. Is the accepted practice to 'spread' the 103 people over the interval between 85.6% and 91.6% and calculate the resulting percentile as 87.1%? Or, is the accepted practice to do something else? Thanks, Gene Maguin |
| Free forum by Nabble | Edit this page |
