hello all,
I was trying to use LOOP to write syntax for looping over a graph and a regression. There are a number of samples for each individual. I want to loop over all the samples of each individual in turn, so first get all the samples for individual 1 (code 1 below), then all the samples for individual 2 etc. I read other postings on here and realized I had to use SPLIT FILE, so I did. For each individual, I want a scatterplot and a regression done. I thought the output would come out as (scatterplot, regression) for individual 1, then (scatterplot, regression) for individual 2, etc, but it hasn't. Instead I get all scatterplots first, then all regressions. Is there a way to modify that? The syntax I wrote is the following: SORT CASES BY code. SPLIT FILE SEPARATE BY code. IGRAPH /VIEWNAME='Scatterplot' /X1=VAR(days) TYPE=SCALE /Y=VAR(AFP ) TYPE=SCALE /COORDINATE=VERTICAL /FITLINE METHOD=REGRESSION LINEAR LINE=TOTAL SPIKE=OFF /CHARTLOOK='NONE' /SCATTER COINCIDENT=NONE /POINTLABEL= VAR(sampleno) all. REGRESSION /MISSING LISTWISE /CRITERIA=PIN(.05) POUT(.10) /NOORIGIN /DEPENDENT resultAFP /METHOD=ENTER daysfromlastscreening /SAVE PRED ZPRED ADJPRED SEPRED COOK LEVER RESID ZRESID SRESID DRESID SDRESID /RESIDUALS HISTOGRAM(ZRESID) ID(sampleno). OUTPUT EXPORT /DOC DOCUMENTFILE='H:\out.doc'. SPLIT FILE OFF. USE ALL. SAVE OUTFILE='H:\afph1.sav' /COMPRESSED. Another question I have, is how can I save e.g. the correlation coefficient after a linear regression i.e. get SPSS to output it in a file, and do that for all the regressions run, so that in the end I have a file with a column of correlation coefficients. I know you can save residuals from a regression in your data file, but what if I want to save something that is not under the "save options" in SPSS? Thank you all |
Split files iterates within a procedure.
There is no way to make it iterate over an entire batch of syntax.
However, there is a pair of extension commands, SPSSINC SPLIT DATASET
and SPSSINC PROCESS FILES that can iterate an entire syntax file similar
to split files. The first command breaks the dataset into separate
files, and the second one applies the syntax to each in turn. PROCESS
files sets up file handles and macros so that the syntax can work directly
with each file. Standard syntax and a dialog box interface are provided
for both.
These require the Python Essentials and a download of these two commands. All available (free) from the SPSS Community site (www.ibm.com/developerworks/spssdevcentral). Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: xenia <[hidden email]> To: [hidden email], Date: 10/18/2012 07:17 AM Subject: [SPSSX-L] looping, split file and saving Sent by: "SPSSX(r) Discussion" <[hidden email]> hello all, I was trying to use LOOP to write syntax for looping over a graph and a regression. There are a number of samples for each individual. I want to loop over all the samples of each individual in turn, so first get all the samples for individual 1 (code 1 below), then all the samples for individual 2 etc. I read other postings on here and realized I had to use SPLIT FILE, so I did. For each individual, I want a scatterplot and a regression done. I thought the output would come out as (scatterplot, regression) for individual 1, then (scatterplot, regression) for individual 2, etc, but it hasn't. Instead I get all scatterplots first, then all regressions. Is there a way to modify that? The syntax I wrote is the following: SORT CASES BY code. SPLIT FILE SEPARATE BY code. IGRAPH /VIEWNAME='Scatterplot' /X1=VAR(days) TYPE=SCALE /Y=VAR(AFP ) TYPE=SCALE /COORDINATE=VERTICAL /FITLINE METHOD=REGRESSION LINEAR LINE=TOTAL SPIKE=OFF /CHARTLOOK='NONE' /SCATTER COINCIDENT=NONE /POINTLABEL= VAR(sampleno) all. REGRESSION /MISSING LISTWISE /CRITERIA=PIN(.05) POUT(.10) /NOORIGIN /DEPENDENT resultAFP /METHOD=ENTER daysfromlastscreening /SAVE PRED ZPRED ADJPRED SEPRED COOK LEVER RESID ZRESID SRESID DRESID SDRESID /RESIDUALS HISTOGRAM(ZRESID) ID(sampleno). OUTPUT EXPORT /DOC DOCUMENTFILE='H:\out.doc'. SPLIT FILE OFF. USE ALL. SAVE OUTFILE='H:\afph1.sav' /COMPRESSED. Another question I have, is how can I save e.g. the correlation coefficient after a linear regression i.e. get SPSS to output it in a file, and do that for all the regressions run, so that in the end I have a file with a column of correlation coefficients. I know you can save residuals from a regression in your data file, but what if I want to save something that is not under the "save options" in SPSS? Thank you all -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/looping-split-file-and-saving-tp5715711.html Sent from the SPSSX Discussion mailing list archive at Nabble.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 |
Administrator
|
In reply to this post by xenia
See DEFINE !ENDDEFINE in FM. Within that see !DO .
also see TEMPORARY followed by SELECT IF , alternatively FILTER . DEFINE mloop () !DO !I=1 !TO 1000. COMPUTE @Filt = (code EQ !I) . FILTER BY @Filt . graph command. regression command !DOEND !ENDDEFINE . mloop . For Correlation see MATRIX OUT on Correlation/Regression/Factor etc command supports SPLIT FILE. ---
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
In reply to this post by xenia
This is UNTESTED, but I think a good old fashioned macro will work here. Something like this.
* Define a macro. DEFINE !MySplit (CodeList = !CMDEND) !ENDDEFINE. !DO !C !IN (!CodeList) USE ALL. COMPUTE F = code EQ !C . FILTER BY F. IGRAPH /VIEWNAME='Scatterplot' /X1=VAR(days) TYPE=SCALE /Y=VAR(AFP ) TYPE=SCALE /COORDINATE=VERTICAL /FITLINE METHOD=REGRESSION LINEAR LINE=TOTAL SPIKE=OFF /CHARTLOOK='NONE' /SCATTER COINCIDENT=NONE /POINTLABEL= VAR(sampleno) all. REGRESSION /MISSING LISTWISE /CRITERIA=PIN(.05) POUT(.10) /NOORIGIN /DEPENDENT resultAFP /METHOD=ENTER daysfromlastscreening /SAVE PRED ZPRED ADJPRED SEPRED COOK LEVER RESID ZRESID SRESID DRESID SDRESID /RESIDUALS HISTOGRAM(ZRESID) ID(sampleno). !DOEND USE ALL. FILTER OFF. !ENDDEFINE. * Call the macro, handing it a list of codes . * Set MPRINT to ON at least initially (for debugging). * When the macro is working, you may wish to comment it out. SET MPRINT ON. !MySplit CodeList = 1 2 3 4 5. SET MPRINT OFF. OUTPUT EXPORT /DOC DOCUMENTFILE='H:\out.doc'. SAVE OUTFILE='H:\afph1.sav' /COMPRESSED.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
In reply to this post by Jon K Peck
Thank you all for your suggestions, I will try them out.
On 18 October 2012 14:26, Jon K Peck <[hidden email]> wrote: > Split files iterates within a procedure. There is no way to make it iterate > over an entire batch of syntax. However, there is a pair of extension > commands, SPSSINC SPLIT DATASET and SPSSINC PROCESS FILES that can iterate > an entire syntax file similar to split files. The first command breaks the > dataset into separate files, and the second one applies the syntax to each > in turn. PROCESS files sets up file handles and macros so that the syntax > can work directly with each file. Standard syntax and a dialog box > interface are provided for both. > > These require the Python Essentials and a download of these two commands. > All available (free) from the SPSS Community site > (www.ibm.com/developerworks/spssdevcentral). > > > Jon Peck (no "h") aka Kim > Senior Software Engineer, IBM > [hidden email] > new phone: 720-342-5621 > > > > > From: xenia <[hidden email]> > To: [hidden email], > Date: 10/18/2012 07:17 AM > Subject: [SPSSX-L] looping, split file and saving > Sent by: "SPSSX(r) Discussion" <[hidden email]> > ________________________________ > > > > hello all, > I was trying to use LOOP to write syntax for looping over a graph and a > regression. There are a number of samples for each individual. I want to > loop over all the samples of each individual in turn, so first get all the > samples for individual 1 (code 1 below), then all the samples for individual > 2 etc. I read other postings on here and realized I had to use SPLIT FILE, > so I did. For each individual, I want a scatterplot and a regression done. I > thought the output would come out as (scatterplot, regression) for > individual 1, then (scatterplot, regression) for individual 2, etc, but it > hasn't. Instead I get all scatterplots first, then all regressions. Is there > a way to modify that? > The syntax I wrote is the following: > > SORT CASES BY code. > SPLIT FILE SEPARATE BY code. > > IGRAPH > /VIEWNAME='Scatterplot' > /X1=VAR(days) TYPE=SCALE > /Y=VAR(AFP ) TYPE=SCALE > /COORDINATE=VERTICAL > /FITLINE METHOD=REGRESSION LINEAR LINE=TOTAL SPIKE=OFF > /CHARTLOOK='NONE' > /SCATTER COINCIDENT=NONE > /POINTLABEL= VAR(sampleno) all. > > REGRESSION > /MISSING LISTWISE > /CRITERIA=PIN(.05) POUT(.10) > /NOORIGIN > /DEPENDENT resultAFP > /METHOD=ENTER daysfromlastscreening > /SAVE PRED ZPRED ADJPRED SEPRED COOK LEVER RESID ZRESID SRESID DRESID > SDRESID > /RESIDUALS HISTOGRAM(ZRESID) ID(sampleno). > > > OUTPUT EXPORT > /DOC DOCUMENTFILE='H:\out.doc'. > > SPLIT FILE OFF. > USE ALL. > > SAVE OUTFILE='H:\afph1.sav' > /COMPRESSED. > > Another question I have, is how can I save e.g. the correlation coefficient > after a linear regression i.e. get SPSS to output it in a file, and do that > for all the regressions run, so that in the end I have a file with a column > of correlation coefficients. I know you can save residuals from a regression > in your data file, but what if I want to save something that is not under > the "save options" in SPSS? > > Thank you all > > > > > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/looping-split-file-and-saving-tp5715711.html > Sent from the SPSSX Discussion mailing list archive at Nabble.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 |
In reply to this post by Bruce Weaver
The macro may work (but what's that extra
!enddefine?), but it requires the user to list all the individual id's.
If there are only a few, that's not so bad, but with many, it is
tedious and error prone. The extension commands I suggested will
iterate over all the values automatically.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: Bruce Weaver <[hidden email]> To: [hidden email], Date: 10/18/2012 08:18 AM Subject: Re: [SPSSX-L] looping, split file and saving Sent by: "SPSSX(r) Discussion" <[hidden email]> This is UNTESTED, but I think a good old fashioned macro will work here. Something like this. * Define a macro. DEFINE !MySplit (CodeList = !CMDEND) !ENDDEFINE. !DO !C !IN (!CodeList) USE ALL. COMPUTE F = code EQ !C . FILTER BY F. IGRAPH /VIEWNAME='Scatterplot' /X1=VAR(days) TYPE=SCALE /Y=VAR(AFP ) TYPE=SCALE /COORDINATE=VERTICAL /FITLINE METHOD=REGRESSION LINEAR LINE=TOTAL SPIKE=OFF /CHARTLOOK='NONE' /SCATTER COINCIDENT=NONE /POINTLABEL= VAR(sampleno) all. REGRESSION /MISSING LISTWISE /CRITERIA=PIN(.05) POUT(.10) /NOORIGIN /DEPENDENT resultAFP /METHOD=ENTER daysfromlastscreening /SAVE PRED ZPRED ADJPRED SEPRED COOK LEVER RESID ZRESID SRESID DRESID SDRESID /RESIDUALS HISTOGRAM(ZRESID) ID(sampleno). !DOEND USE ALL. FILTER OFF. !ENDDEFINE. * Call the macro, handing it a list of codes . * Set MPRINT to ON at least initially (for debugging). * When the macro is working, you may wish to comment it out. SET MPRINT ON. !MySplit CodeList = 1 2 3 4 5. SET MPRINT OFF. OUTPUT EXPORT /DOC DOCUMENTFILE='H:\out.doc'. SAVE OUTFILE='H:\afph1.sav' /COMPRESSED. xenia wrote > hello all, > I was trying to use LOOP to write syntax for looping over a graph and a > regression. There are a number of samples for each individual. I want to > loop over all the samples of each individual in turn, so first get all the > samples for individual 1 (code 1 below), then all the samples for > individual 2 etc. I read other postings on here and realized I had to use > SPLIT FILE, so I did. For each individual, I want a scatterplot and a > regression done. I thought the output would come out as (scatterplot, > regression) for individual 1, then (scatterplot, regression) for > individual 2, etc, but it hasn't. Instead I get all scatterplots first, > then all regressions. Is there a way to modify that? > The syntax I wrote is the following: > > SORT CASES BY code. > SPLIT FILE SEPARATE BY code. > > IGRAPH > /VIEWNAME='Scatterplot' > /X1=VAR(days) TYPE=SCALE > /Y=VAR(AFP ) TYPE=SCALE > /COORDINATE=VERTICAL > /FITLINE METHOD=REGRESSION LINEAR LINE=TOTAL SPIKE=OFF > /CHARTLOOK='NONE' > /SCATTER COINCIDENT=NONE > /POINTLABEL= VAR(sampleno) all. > > REGRESSION > /MISSING LISTWISE > /CRITERIA=PIN(.05) POUT(.10) > /NOORIGIN > /DEPENDENT resultAFP > /METHOD=ENTER daysfromlastscreening > /SAVE PRED ZPRED ADJPRED SEPRED COOK LEVER RESID ZRESID SRESID DRESID > SDRESID > /RESIDUALS HISTOGRAM(ZRESID) ID(sampleno). > > > OUTPUT EXPORT > /DOC DOCUMENTFILE='H:\out.doc'. > > SPLIT FILE OFF. > USE ALL. > > SAVE OUTFILE='H:\afph1.sav' > /COMPRESSED. > > Another question I have, is how can I save e.g. the correlation > coefficient after a linear regression i.e. get SPSS to output it in a > file, and do that for all the regressions run, so that in the end I have a > file with a column of correlation coefficients. I know you can save > residuals from a regression in your data file, but what if I want to save > something that is not under the "save options" in SPSS? > > Thank you all ----- -- |
Administrator
|
Just AUTORECODE and use my posted solution subtituting the MAX for 1000 and you are ready to rock and roll!
I almost want to abuse a line from Treasure of Sierra Madre... " User of Sierra Madre "We don't need a no stinkin python ;-))" --
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by Jon K Peck
Folks, Miserable me. When my company upgraded to Windows 7, I had to reinstall SPSS 15. I used the installation disk to reinstall Python 2.4 and the SPSS-Python Integration Program. I copied spssaux from my hard drive, the version created 7/21/2008. Now running a program that I successfully run regularly on my XP machine, I get the following error at the end of the BEGIN PROGRAM/END PROGRAM sequence: Traceback (most recent call last): File "<string>", line 1, in ? ImportError: Bad magic number in C:\Python24\lib\site-packages\spssaux\__init__.pyc My hunch is that I have copied the wrong version of spssaux to
C:\Python24\Lib\site-packages\ but I don't know. Any ideas? Jon? Kim? Albert? HELP! Cheers everyone, King Douglas American Airlines
|
The spssaux module is not version specific.
My guess is that something is wrong with the .pyc files, although
I don't recall seeing this message. Try deleting all the .pyc files
in the spssaux, spssdata, and spss subdirectories under site-packages.
Python will automatically recompile all of these.
You can get newer versions of spssaux.py and spssdata.py from the SPSS Community site, but I don't think that is the issue here. HTH, Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: King Douglas <[hidden email]> To: Jon K Peck/Chicago/IBM@IBMUS, [hidden email], Date: 10/18/2012 08:54 AM Subject: "Bad magic number" spssaux module using SPSS 15 and Python 2.4 Folks, Miserable me. When my company upgraded to Windows 7, I had to reinstall SPSS 15. I used the installation disk to reinstall Python 2.4 and the SPSS-Python Integration Program. I copied spssaux from my hard drive, the version created 7/21/2008. Now running a program that I successfully run regularly on my XP machine, I get the following error at the end of the BEGIN PROGRAM/END PROGRAM sequence: Traceback (most recent call last): File "<string>", line 1, in ? ImportError: Bad magic number in C:\Python24\lib\site-packages\spssaux\__init__.pyc My hunch is that I have copied the wrong version of spssaux to C:\Python24\Lib\site-packages\ but I don't know. Any ideas? Jon? Kim? Albert? HELP! Cheers everyone, King Douglas American Airlines |
I'm not in the office until 08:00 Monday 29th October 2012 - I will try and respond on my return. The University of Aberdeen is a charity registered in Scotland, No SC013683. |
In reply to this post by Jon K Peck
Thanks, Jon, I'll give it a shot and report back. King From: Jon K Peck <[hidden email]> To: [hidden email] Sent: Thu, October 18, 2012 10:10:48 AM Subject: Re: "Bad magic number" spssaux module using SPSS 15 and Python 2.4 The spssaux module is not version specific. My guess is that something is wrong with the .pyc files, although I don't recall seeing this message. Try deleting all the .pyc files in the spssaux, spssdata, and spss subdirectories under site-packages. Python will automatically recompile all of these. You can get newer versions of spssaux.py and spssdata.py from the SPSS Community site, but I don't think that is the issue here. HTH, Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: King Douglas <[hidden email]> To: Jon K Peck/Chicago/IBM@IBMUS, [hidden email], Date: 10/18/2012 08:54 AM Subject: "Bad magic number" spssaux module using SPSS 15 and Python 2.4 Folks, Miserable me. When my company upgraded to Windows 7, I had to reinstall SPSS 15. I used the installation disk to reinstall Python 2.4 and the SPSS-Python Integration Program. I copied spssaux from my hard drive, the version created 7/21/2008. Now running a program that I successfully run regularly on my XP machine, I get the following error at the end of the BEGIN PROGRAM/END PROGRAM sequence: Traceback (most recent call last): File "<string>", line 1, in ? ImportError: Bad magic number in C:\Python24\lib\site-packages\spssaux\__init__.pyc My hunch is that I have copied the wrong version of spssaux to C:\Python24\Lib\site-packages\ but I don't know. Any ideas? Jon? Kim? Albert? HELP! Cheers everyone, King Douglas American Airlines |
Administrator
|
In reply to this post by Jon K Peck
"The macro may work (but what's that extra !enddefine?)"
Would you believe I stuck it in there deliberately to see if anyone was paying attention? ;-) Nice catch, Jon. And I agree it's not ideal if the number of codes is large. bw
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
In reply to this post by Bruce Weaver
hello again,
got round to trying this. When I run it I get the following in Viewer: DEFINE !MySplit (CodeList = !CMDEND) !ENDDEFINE. !DO !C !IN (!CodeList) >Error # 1. Command name: !DO >The first word in the line is not recognized as an SPSS Statistics command. >Execution of this command stops. USE ALL. COMPUTE F = code EQ !C . >Warning # 210 in column 21. Text: !C >A macro symbol is invalid in this context. >The symbol will be treated as an invalid special character. >Error # 4007 in column 21. Text: !C >The expression is incomplete. Check for missing operands, invalid operators, >unmatched parentheses or excessive string length. >Execution of this command stops. FILTER BY F. >Error # 4872 in column 11. Text: F >The name of the filter variable is undefined. Either the variable has not >been defined or its name has been misspelled. >Execution of this command stops. I can't use J.Peck's suggestion as I don't have administrative rights in order to be able to download and install from a site. |
I am currently out of the office and will respond to your email, if necessary, on Monday, November 19. If you need immediate assistance, please
call 812-856-5824.
Shimon Sarraf Center for Postsecondary Research Indiana University Bloomington
|
Administrator
|
In reply to this post by xenia
Bruce had an extra !ENDDEFINE !
Get rid of the first one immediately following the DEFINE line. Keep the one at the END of the original code. --
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
In reply to this post by xenia
"I can't use J.Peck's suggestion as I don't have administrative rights in order to be able to download and install from a site. "
Heed ye all macro hating python evangelists! Once upon a time I did a 3 month onsite consulting gig for a bank and the IT was so locked down it took 3 weeks of begging to even get SPSS installed (that took me begging my supervisor to beg his supervisor to simply install the tools I needed to do the job they were paying me big bucks per hour). If I were to have required Python it would have been likely 4 months. I am currently working on a rather complex (bleeding edge statistical method) matrix macro for an academic client which will be distributed to many end users down stream within an academic research context. If all of these users required a python installation to use my work it would be a real PITA to support. In this case the macro is simply a wrapper for passing variable names and control parameters so why would I bother complicating it with python? Sometimes a hammer is just a hammer!
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Heed you few Python hating folks.
Python and the Python Essentials require no more privileges to install than Statistics itself. If it is done later, though, and IT was required to do the install, you might have to get IT back to install the Essentials. Additional extension commands require no privileges (assuming that the entire disk is not locked down, which I have seen), but permission to create a Registry key on Windows might be required if the normal areas are locked down. From a security viewpoint, you could do almost as much damage with a Basic script in Statistics as with Python - or the HOST command, for that matter. As of V21, extensions can be installed in an area normally writable for any user, and the Essentials are included with the installation media or download. I think the one remaining good use for macro is as a shorthand for a list of variables or similar with no logic in it. Otherwise, Python is much simpler and way more powerful. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: David Marso <[hidden email]> To: [hidden email], Date: 11/15/2012 11:49 AM Subject: Re: [SPSSX-L] looping, split file and saving Sent by: "SPSSX(r) Discussion" <[hidden email]> "I can't use J.Peck's suggestion as I don't have administrative rights in order to be able to download and install from a site. " Heed ye all macro hating python evangelists! Once upon a time I did a 3 month onsite consulting gig for a bank and the IT was so locked down it took 3 weeks of begging to even get SPSS installed (that took me begging my supervisor to beg his supervisor to simply install the tools I needed to do the job they were paying me big bucks per hour). If I were to have required Python it would have been likely 4 months. I am currently working on a rather complex (bleeding edge statistical method) matrix macro for an academic client which will be distributed to many end users down stream within an academic research context. If all of these users required a python installation to use my work it would be a real PITA to support. In this case the macro is simply a wrapper for passing variable names and control parameters so why would I bother complicating it with python? Sometimes a hammer is just a hammer! ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/looping-split-file-and-saving-tp5715711p5716236.html Sent from the SPSSX Discussion mailing list archive at Nabble.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 |
Administrator
|
JoHoh,
First off I don't hate python! In fact I own 2 books on the subject. Until I can justify spending a couple grand on upgrading SPSS I do not have ready access to a version which supports python. AND I don't wish to provide a solution to a client where 1. he/she is the front line support to a myriad of end users with unknown level of IT support/technical competency etc (leaving that person holding the bag). 2. Involving python is NOT an intrinsic requirement (ie, no need to access metadata or data values). Consider. DEFINE f1 (args). MATRIX code ..... !ENDDEFINE. DEFINE f2 (args). MATRIX code ..... !ENDDEFINE. ....... ....... DEFINE fN (args). ... !ENDDEFINE. DEFINE MAIN (arg1 !TOKENS(1)/.......arg2 arg3 ......argZrg). preprocessing... MATRIX. GET data .... !IF (arg1 !EQ value) !THEN f3 !arg2 f4 !argk .... fk !arg... !ELSE. f5 f6 ..... !IFEND ** Do common processing here . fX fY fZ ... Report results.... END MATRIX. !ENDDEFINE. Basically I have a relatively large MATRIX program spanning about 15-20 pages There are 2 basic methods which share some calculations but have major differences. Rather than have 1 HUGE difficult to debug MATRIX END MATRIX block I have opted to partition it into several logically independent blocks each consisting of a macro header with arguments . The body of each MACRO contains MATRIX calculations. Pretty nifty. Sure, one could probably set that up in python, but why bother. Whatever floats your boat! ----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
One point to consider is that if you wrapped
the entire thing in Python as an extension command, once installed, the
user would never need to remember to load/insert/include it in order to
use it. Another point is much easier protection in case of user errors.
If the user leaves out a required macro argument or specifies something
of the wrong type, the error messages are likely to be quite mysterious.
With an extension command, this can be handled very smoothly and
with very little development effort.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: David Marso <[hidden email]> To: [hidden email], Date: 11/15/2012 02:35 PM Subject: Re: [SPSSX-L] looping, split file and saving Sent by: "SPSSX(r) Discussion" <[hidden email]> JoHoh, First off I don't hate python! In fact I own 2 books on the subject. Until I can justify spending a couple grand on upgrading SPSS I do not have ready access to a version which supports python. AND I don't wish to provide a solution to a client where 1. he/she is the front line support to a myriad of end users with unknown level of IT support/technical competency etc (leaving that person holding the bag). 2. Involving python is NOT an intrinsic requirement (ie, no need to access metadata or data values). Consider. DEFINE f1 (args). MATRIX code ..... !ENDDEFINE. DEFINE f2 (args). MATRIX code ..... !ENDDEFINE. ....... ....... DEFINE fN (args). ... !ENDDEFINE. DEFINE MAIN (arg1 !TOKENS(1)/.......arg2 arg3 ......argZrg). preprocessing... MATRIX. GET data .... !IF (arg1 !EQ value) !THEN f3 !arg2 f4 !argk .... fk !arg... !ELSE. f5 f6 ..... !IFEND ** Do common processing here . fX fY fZ ... Report results.... END MATRIX. !ENDDEFINE. Basically I have a relatively large MATRIX program spanning about 15-20 pages There are 2 basic methods which share some calculations but have major differences. Rather than have 1 HUGE difficult to debug MATRIX END MATRIX block I have opted to partition it into several logically independent blocks each consisting of a macro header with arguments . The body of each MACRO contains MATRIX calculations. Pretty nifty. Sure, one could probably set that up in python, but why bother. Whatever floats your boat! ---- Jon K Peck wrote > Heed you few Python hating folks. > > Python and the Python Essentials require no more privileges to install > than Statistics itself. If it is done later, though, and IT was required > to do the install, you might have to get IT back to install the > Essentials. Additional extension commands require no privileges (assuming > that the entire disk is not locked down, which I have seen), but > permission to create a Registry key on Windows might be required if the > normal areas are locked down. From a security viewpoint, you could do > almost as much damage with a Basic script in Statistics as with Python - > or the HOST command, for that matter. > > As of V21, extensions can be installed in an area normally writable for > any user, and the Essentials are included with the installation media or > download. > > I think the one remaining good use for macro is as a shorthand for a list > of variables or similar with no logic in it. Otherwise, Python is much > simpler and way more powerful. > > > Jon Peck (no "h") aka Kim > Senior Software Engineer, IBM > peck@.ibm > new phone: 720-342-5621 > > > > > From: David Marso < > david.marso@ > > > To: > SPSSX-L@.uga > , > Date: 11/15/2012 11:49 AM > Subject: Re: [SPSSX-L] looping, split file and saving > Sent by: "SPSSX(r) Discussion" < > SPSSX-L@.uga > > > > > > "I can't use J.Peck's suggestion as I don't have administrative rights in > order to be able to download and install from a site. " > > Heed ye all macro hating python evangelists! > Once upon a time I did a 3 month onsite consulting gig for a bank and the > IT > was so locked down it took 3 weeks of begging to even get SPSS installed > (that took me begging my supervisor to beg his supervisor to simply > install > the tools I needed to do the job they were paying me big bucks per hour). > If I were to have required Python it would have been likely 4 months. > > I am currently working on a rather complex (bleeding edge statistical > method) matrix macro for an academic client which will be distributed to > many end users down stream within an academic research context. If all of > these users required a python installation to use my work it would be a > real > PITA to support. > > In this case the macro is simply a wrapper for passing variable names and > control parameters so why would I bother complicating it with python? > Sometimes a hammer is just a hammer! > > > > ----- > Please reply to the list and not to my personal email. > Those desiring my consulting or training services please feel free to > email me. > -- > View this message in context: > http://spssx-discussion.1045642.n5.nabble.com/looping-split-file-and-saving-tp5715711p5716236.html > > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (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 ----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/looping-split-file-and-saving-tp5715711p5716238.html Sent from the SPSSX Discussion mailing list archive at Nabble.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 |
Administrator
|
Point taken. Maybe ver 2 (after I get my mitts on v 21. OTOH my 11.5 circa 2003 is FULLY LOADED with ***ALL OPTIONS*** to upgrade that to v 21 would run me close to 20K. So unless I win the lottery or the suits at IBM decide out of the kindness of their hearts and infinite benevolence and generosity to donate me a copy for my endless community service and time served I will remain a Python free dinosaur. Maybe a trade for developing new toys ?? Nah, they love the cold hard cash!
"If the user leaves out a required macro argument or specifies something of the wrong type, the error messages are likely to be quite mysterious." NOPE!!! I write idiot proof code and document the hell out of it! Problem is that nature keeps on creating new and improved idiots (keeps me on my toes)! Remember JoNoH, I've been building these type of things for over 15 yrs and know WTF I am doing and did SPSS teksport for 5 so know how 'dumb users' think and do! In my case: The default invocation is simply the name of the macro. Alternatively MacroName METHOD=value. The other arguments are to over ride default variable names which are pretty generic. If the user forgets to insert or include then it is really a Dr Dr situation(it hurts when I do this). --
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Free forum by Nabble | Edit this page |