looping, split file and saving

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

Re: Python vs MACRO was: Re: looping, split file and saving

Jon K Peck
Presumably all this computation requires some data, so there must be something more to specify.

Another point: if you wanted to present the results in a nice pivot table or set of tables, you would need Python in order to generate it (unless you could trick an existing procedure into displaying the data nicely).

Maybe you should write a book and apply to the author program for a deal.  Amazon lists 100 pages of SPSS books, but I don't think that there is a single good one on macro.  There are a lot more options than there were back at 11.5, too.


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 05:49 PM
Subject:        [SPSSX-L] Python vs MACRO was: Re: looping, split file and saving
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




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).
--

Jon K Peck wrote
> 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

> peck@.ibm

> new phone: 720-342-5621
>
>
>
>
> From:   David Marso &lt;

> david.marso@

> &gt;
> To:

> SPSSX-L@.uga

> ,
> Date:   11/15/2012 02:35 PM
> Subject:        Re: [SPSSX-L] looping, split file and saving
> Sent by:        "SPSSX(r) Discussion" &lt;

> SPSSX-L@.uga

> &gt;
>
>
>
> 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 &lt;
>
>> david.marso@
>
>> &gt;
>> 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" &lt;
>
>> SPSSX-L@.uga
>
>> &gt;
>>
>>
>>
>> "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

> 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-tp5715711p5716243.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


Reply | Threaded
Open this post in threaded view
|

Re: Python vs MACRO was: Re: looping, split file and saving

David Marso
Administrator
The data are very standardized and specific to a very well defined task so seriously, that is all that requires specification aside from using one name as a proxy for a default field ;-)
Without violating some NDA I can say the following.
This project calculates Effect Sizes for some rather special research designs (details are confidential) which are input into other macros (some of which I wrote last year) for Meta analytic work (so the output is really a new data set and nobody really looks at them in a tabular requirement).  
This is part of an ongoing group of research projects with several grants and several overlapping teams of prominent researchers and they have worked out some pretty nice standards for their data requirements.  I'm on board to do the heavy lifting WRT matrix programming and solution development.  They do the theory and prototyping in R and then I go to town with SPSS.  
Pretty nice relationship.    I know one can run R from SPSS and they know that but they desire/require a native SPSS solution.

If I wanted to create a Pivot TABLE then I could do that with BASIC scripting.

But why pray tell would I bother to write a book involving MACRO when it is so 20th century (obsolete/deprecated/useless/powerless)?  Why would IBM want me to?  Why would I want to jump through all sorts of corporate hoops and deal with the suits and the lawyers?  Next thing I know I would be sued for reposting my own code on this forum from the book.  
If I were to write a book about SPSS it would be incredibly deep and nobody except maybe 10-20 people from this forum would want to (or be able to) read it.  Think Hard-Core SPSS (after Bruce McKinney's Hard Core Visual Basic).  It would make ?Raynald's?  book look like an introductory guide for the slightly perplexed ;-) .  In other words it would have a very limited audience and would likely not be of interest to IBM since in my opinion they could really care less about advanced user requirements.
Last year I offered to do a Beta testing for ver 20.  When I asked A.R. about a possible free copy for doing a LOT of testing of the more exotic/complex features he declined and I mysteriously was 'disappeared' from the list of testers.  He didn't even bother to return my email when I challenged him.
OTOH:  If you think such a project would be of interest to the powers that be maybe you could champion the idea to appropriate parties?  After all, they don't know me from Adam (but you do).



Jon K Peck wrote

Presumably all this computation requires some data, so there must be
something more to specify.

Another point: if you wanted to present the results in a nice pivot table
or set of tables, you would need Python in order to generate it (unless
you could trick an existing procedure into displaying the data nicely).

Maybe you should write a book and apply to the author program for a deal.
Amazon lists 100 pages of SPSS books, but I don't think that there is a
single good one on macro.  There are a lot more options than there were
back at 11.5, too.


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 05:49 PM
Subject:        [SPSSX-L] Python vs MACRO was: Re: looping, split file and
saving
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



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).
--

Jon K Peck wrote
> 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

> peck@.ibm

> new phone: 720-342-5621
>
>
>
>
> From:   David Marso <

> david.marso@

> >
> To:

> SPSSX-L@.uga

> ,
> Date:   11/15/2012 02:35 PM
> Subject:        Re: [SPSSX-L] looping, split file and saving
> Sent by:        "SPSSX(r) Discussion" <

> SPSSX-L@.uga

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

> 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-tp5715711p5716243.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
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Python vs MACRO was: Re: looping, split file and saving

Albert-Jan Roskam
In reply to this post by Jon K Peck
 
<snip>
 
 
>> 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.
>>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
As of v21?  In v20, provided the user has rights to do so, the values of environment variables
spss_cdialogs_path and spss_extensions_path could already be extended or modified.
What is the difference?
 
 
 
 
 
 
 
 
 
>> 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.

import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex. <--------------
Complex is better than complicated.  <--------------
Flat is better than nested.
Sparse is better than dense.
Readability counts.  <--------------
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.  <-------------- applies to me, at least ;-)
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Reply | Threaded
Open this post in threaded view
|

Re: Python vs MACRO was: Re: looping, split file and saving

Ruben Geert van den Berg
>> 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.

When it comes to defining and using lists of variables, I really like to use the "TO" keyword ("var_a var_b var_e TO var_h var_m"). Python handles this flawlessly but how can I use this list in a macro? And what if there are many (say, 100) variables between "var_e" and "var_h"?

On top of that, with Python one can very easily generate and use a list of all variables which have a given pattern in their names, variable labels or even value labels without bothering about their order in the data.

IMHO, one of the (many) great features of Python is that it can save you from a lot of manual typing by simply retrieving things like variable names, file names, excel sheet names (and so on) from the data.

Kind regards,

Ruben

import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex. <--------------
Complex is better than complicated.  <--------------
Flat is better than nested.
Sparse is better than dense.
Readability counts.  <--------------
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.  <-------------- applies to me too
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Reply | Threaded
Open this post in threaded view
|

Re: Python vs MACRO was: Re: looping, split file and saving

xenia
In reply to this post by David Marso
How can one run R from SPSS?


On 16 November 2012 02:28, David Marso [via SPSSX Discussion] <[hidden email]> wrote:
The data are very standardized and specific to a very well defined task so seriously, that is all that requires specification aside from using one name as a proxy for a default field ;-)
Without violating some NDA I can say the following.
This project calculates Effect Sizes for some rather special research designs (details are confidential) which are input into other macros (some of which I wrote last year) for Meta analytic work (so the output is really a new data set and nobody really looks at them in a tabular requirement).  
This is part of an ongoing group of research projects with several grants and several overlapping teams of prominent researchers and they have worked out some pretty nice standards for their data requirements.  I'm on board to do the heavy lifting WRT matrix programming and solution development.  They do the theory and prototyping in R and then I go to town with SPSS.  
Pretty nice relationship.    I know one can run R from SPSS and they know that but they desire/require a native SPSS solution.

If I wanted to create a Pivot TABLE then I could do that with BASIC scripting.

But why pray tell would I bother to write a book involving MACRO when it is so 20th century (obsolete/deprecated/useless/powerless)?  Why would IBM want me to?  Why would I want to jump through all sorts of corporate hoops and deal with the suits and the lawyers?  Next thing I know I would be sued for reposting my own code on this forum from the book.  
If I were to write a book about SPSS it would be incredibly deep and nobody except maybe 10-20 people from this forum would want to (or be able to) read it.  Think Hard-Core SPSS (after Bruce McKinney's Hard Core Visual Basic).  It would make ?Raynald's?  book look like an introductory guide for the slightly perplexed ;-) .  In other words it would have a very limited audience and would likely not be of interest to IBM since in my opinion they could really care less about advanced user requirements.
Last year I offered to do a Beta testing for ver 20.  When I asked A.R. about a possible free copy for doing a LOT of testing of the more exotic/complex features he declined and I mysteriously was 'disappeared' from the list of testers.  He didn't even bother to return my email when I challenged him.
OTOH:  If you think such a project would be of interest to the powers that be maybe you could champion the idea to appropriate parties?  After all, they don't know me from Adam (but you do).



Jon K Peck wrote

Presumably all this computation requires some data, so there must be
something more to specify.

Another point: if you wanted to present the results in a nice pivot table
or set of tables, you would need Python in order to generate it (unless
you could trick an existing procedure into displaying the data nicely).

Maybe you should write a book and apply to the author program for a deal.
Amazon lists 100 pages of SPSS books, but I don't think that there is a
single good one on macro.  There are a lot more options than there were
back at 11.5, too.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: <a href="tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621




From:   David Marso <[hidden email]>
To:     [hidden email],
Date:   11/15/2012 05:49 PM
Subject:        [SPSSX-L] Python vs MACRO was: Re: looping, split file and
saving
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



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).
--

Jon K Peck wrote
> 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

> peck@.ibm

> new phone: <a href="tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621
>
>
>
>
> From:   David Marso <

> david.marso@

> >
> To:

> SPSSX-L@.uga

> ,
> Date:   11/15/2012 02:35 PM
> Subject:        Re: [SPSSX-L] looping, split file and saving
> Sent by:        "SPSSX(r) Discussion" <

> SPSSX-L@.uga

> >
>
>
>
> 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: <a href="tel:720-342-5621" value="+17203425621" target="_blank">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

> 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-tp5715711p5716243.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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.



If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/looping-split-file-and-saving-tp5715711p5716247.html
To unsubscribe from looping, split file and saving, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Python vs MACRO was: Re: looping, split file and saving

Hart, Kimberly (hartkb)

I am a devoted SPSS user (living in SAS-land) and am new to using R from within SPSS, and I love it. There are a few things that I do like R for, but I simply hate doing any data management with R. I recommend this website: http://r4stats.com/ and the book “R for SAS and SPSS Users: by Robert Muenchen. Kim

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of xenia
Sent: Friday, November 16, 2012 6:45 AM
To: [hidden email]
Subject: Re: Python vs MACRO was: Re: looping, split file and saving

 

How can one run R from SPSS?

 

On 16 November 2012 02:28, David Marso [via SPSSX Discussion] <[hidden email]> wrote:

The data are very standardized and specific to a very well defined task so seriously, that is all that requires specification aside from using one name as a proxy for a default field ;-)
Without violating some NDA I can say the following.
This project calculates Effect Sizes for some rather special research designs (details are confidential) which are input into other macros (some of which I wrote last year) for Meta analytic work (so the output is really a new data set and nobody really looks at them in a tabular requirement).  
This is part of an ongoing group of research projects with several grants and several overlapping teams of prominent researchers and they have worked out some pretty nice standards for their data requirements.  I'm on board to do the heavy lifting WRT matrix programming and solution development.  They do the theory and prototyping in R and then I go to town with SPSS.  
Pretty nice relationship.    I know one can run R from SPSS and they know that but they desire/require a native SPSS solution.

If I wanted to create a Pivot TABLE then I could do that with BASIC scripting.

But why pray tell would I bother to write a book involving MACRO when it is so 20th century (obsolete/deprecated/useless/powerless)?  Why would IBM want me to?  Why would I want to jump through all sorts of corporate hoops and deal with the suits and the lawyers?  Next thing I know I would be sued for reposting my own code on this forum from the book.  
If I were to write a book about SPSS it would be incredibly deep and nobody except maybe 10-20 people from this forum would want to (or be able to) read it.  Think Hard-Core SPSS (after Bruce McKinney's Hard Core Visual Basic).  It would make ?Raynald's?  book look like an introductory guide for the slightly perplexed ;-) .  In other words it would have a very limited audience and would likely not be of interest to IBM since in my opinion they could really care less about advanced user requirements.
Last year I offered to do a Beta testing for ver 20.  When I asked A.R. about a possible free copy for doing a LOT of testing of the more exotic/complex features he declined and I mysteriously was 'disappeared' from the list of testers.  He didn't even bother to return my email when I challenged him.
OTOH:  If you think such a project would be of interest to the powers that be maybe you could champion the idea to appropriate parties?  After all, they don't know me from Adam (but you do).


Jon K Peck wrote


Presumably all this computation requires some data, so there must be
something more to specify.

Another point: if you wanted to present the results in a nice pivot table
or set of tables, you would need Python in order to generate it (unless
you could trick an existing procedure into displaying the data nicely).

Maybe you should write a book and apply to the author program for a deal.
Amazon lists 100 pages of SPSS books, but I don't think that there is a
single good one on macro.  There are a lot more options than there were
back at 11.5, too.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: <a href="<a href="tel:720-342-5621">tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621




From:   David Marso <[hidden email]>
To:     [hidden email],
Date:   11/15/2012 05:49 PM
Subject:        [SPSSX-L] Python vs MACRO was: Re: looping, split file and
saving
Sent by:        "SPSSX(r) Discussion" <[hidden email]>


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).
--

Jon K Peck wrote
> 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: <a href="<a href="tel:720-342-5621">tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621
>
>
>
>
> From:   David Marso <

> david.marso@


> >
> 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
>
>> [hidden email]
>
>> new phone: <a href="<a href="tel:720-342-5621">tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621
>>
>>
>>
>>
>> From:   David Marso <
>

>> david.marso@

>


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





-----
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-tp5715711p5716243.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

Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.

 


If you reply to this email, your message will be added to the discussion below:

http://spssx-discussion.1045642.n5.nabble.com/looping-split-file-and-saving-tp5715711p5716247.html

To unsubscribe from looping, split file and saving, click here.
NAML

 

 


View this message in context: Re: Python vs MACRO was: Re: looping, split file and saving
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Python vs MACRO was: Re: looping, split file and saving

xenia
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Python vs MACRO was: Re: looping, split file and saving

Jon K Peck
In reply to this post by Albert-Jan Roskam
The difference is that V21 will install extensions in the APPDATA area, which is always writable, if other areas are not writable without the need to define environment variables.  Some users don't even  have permission to create environment variables, and Windows does its best to obscure how to do that anyway.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Albert-Jan Roskam <[hidden email]>
To:        [hidden email],
Date:        11/16/2012 02:12 AM
Subject:        Re: [SPSSX-L] Python vs MACRO was: Re: looping,              split file and saving
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




 
<snip>
 
 
>> 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.
>>

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
As of v21?  In v20, provided the user has rights to do so, the values of environment variables
spss_cdialogs_path and spss_extensions_path could already be extended or modified.
What is the difference?
 
 
 
 
 
 
 
 
 
>> 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.


import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex. <--------------
Complex is better than complicated.  <--------------
Flat is better than nested.
Sparse is better than dense.
Readability counts.  <--------------
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.  <-------------- applies to me, at least ;-)
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

Reply | Threaded
Open this post in threaded view
|

Re: Python vs MACRO was: Re: looping, split file and saving

Jon K Peck
In reply to this post by xenia
If  you install the R Essentials from the SPSS Community site (www.ibm.com/developerworks/spssdevcentral in Downloads for SPSS Statistics) you get the plugin and all the documentation on how to do this.  And there are many examples in the Programming and Data Management Book and on the site.


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:        11/16/2012 04:46 AM
Subject:        Re: [SPSSX-L] Python vs MACRO was: Re: looping,              split file and saving
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




How can one run R from SPSS?


On 16 November 2012 02:28, David Marso [via SPSSX Discussion] <[hidden email]> wrote:
The data are very standardized and specific to a very well defined task so seriously, that is all that requires specification aside from using one name as a proxy for a default field ;-)
Without violating some NDA I can say the following.
This project calculates Effect Sizes for some rather special research designs (details are confidential) which are input into other macros (some of which I wrote last year) for Meta analytic work (so the output is really a new data set and nobody really looks at them in a tabular requirement).  
This is part of an ongoing group of research projects with several grants and several overlapping teams of prominent researchers and they have worked out some pretty nice standards for their data requirements.  I'm on board to do the heavy lifting WRT matrix programming and solution development.  They do the theory and prototyping in R and then I go to town with SPSS.  
Pretty nice relationship.    I know one can run R from SPSS and they know that but they desire/require a native SPSS solution.

If I wanted to create a Pivot TABLE then I could do that with BASIC scripting.

But why pray tell would I bother to write a book involving MACRO when it is so 20th century (obsolete/deprecated/useless/powerless)?  Why would IBM want me to?  Why would I want to jump through all sorts of corporate hoops and deal with the suits and the lawyers?  Next thing I know I would be sued for reposting my own code on this forum from the book.  
If I were to write a book about SPSS it would be incredibly deep and nobody except maybe 10-20 people from this forum would want to (or be able to) read it.  Think Hard-Core SPSS (after Bruce McKinney's Hard Core Visual Basic).  It would make ?Raynald's?  book look like an introductory guide for the slightly perplexed ;-) .  In other words it would have a very limited audience and would likely not be of interest to IBM since in my opinion they could really care less about advanced user requirements.
Last year I offered to do a Beta testing for ver 20.  When I asked A.R. about a possible free copy for doing a LOT of testing of the more exotic/complex features he declined and I mysteriously was 'disappeared' from the list of testers.  He didn't even bother to return my email when I challenged him.
OTOH:  If you think such a project would be of interest to the powers that be maybe you could champion the idea to appropriate parties?  After all, they don't know me from Adam (but you do).



Jon K Peck wrote

Presumably all this computation requires some data, so there must be
something more to specify.

Another point: if you wanted to present the results in a nice pivot table
or set of tables, you would need Python in order to generate it (unless
you could trick an existing procedure into displaying the data nicely).

Maybe you should write a book and apply to the author program for a deal.
Amazon lists 100 pages of SPSS books, but I don't think that there is a
single good one on macro.  There are a lot more options than there were
back at 11.5, too.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM

[hidden email]
new phone: <a href="tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621




From:   David Marso <
[hidden email]>
To:    
[hidden email],
Date:   11/15/2012 05:49 PM
Subject:        [SPSSX-L] Python vs MACRO was: Re: looping, split file and
saving
Sent by:        "SPSSX(r) Discussion" <
[hidden email]>



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).
--

Jon K Peck wrote
> 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


> peck@.ibm

> new phone: <a href="tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621
>
>
>
>
> From:   David Marso <

> david.marso@

> >
> To:

> SPSSX-L@.uga

> ,
> Date:   11/15/2012 02:35 PM
> Subject:        Re: [SPSSX-L] looping, split file and saving
> Sent by:        "SPSSX(r) Discussion" <

> SPSSX-L@.uga

> >
>
>
>
> 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: <a href="tel:720-342-5621" value="+17203425621" target="_blank">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

> 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-tp5715711p5716243.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

Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.





If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/looping-split-file-and-saving-tp5715711p5716247.html
To unsubscribe from looping, split file and saving, click here.
NAML



View this message in context: Re: Python vs MACRO was: Re: looping, split file and saving
Sent from the
SPSSX Discussion mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: looping, split file and saving

xenia
In reply to this post by David Marso
Thank you
Reply | Threaded
Open this post in threaded view
|

Automatic reply: looping, split file and saving

Beckstead, Jason

I will be off campus attending the meeting of the Society for Judgment and Decision Making in Minneapolis this weekend and will not be checking email. I will return for classes Monday the 19th.

Reply | Threaded
Open this post in threaded view
|

Automatic reply: [SPSSX-L] looping, split file and saving

Cleland, Patricia (EDU)
In reply to this post by xenia
I am out of the office until November 20 and will not be checking my emails. If your issue is urgent, please contact Caroline Rodrigues ([hidden email]) Otherwise I will reply when I return.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: looping, split file and saving

xenia
In reply to this post by xenia
ok, so got the extra !ENDDEFINE out, the code does what I want, i.e. performs the regression and makes a plot for each individual. However, I do have two problems:
- the list I have to feed in is long. Do I use AUTORECODE (this is what I gather from earlier replies), and where in the code do I use it? is it before declaring the macro?
- with  /SAVE PRED ZPRED ADJPRED SEPRED COOK LEVER RESID ZRESID SRESID DRESID SDRESID in the regression code I save these residuals and distances in my datafile. With SPLIT FILE, the residuals would be written/appended in the same columns at each iteration, now however there are 11 new columns formed with each iteration and the residuals and distances written at the respective rows corresponding to an individual, so in the end I don't have one column for PRED, one column for ZPRED etc but PRED_1, PRED_2,....,PRED_5 e.g. for the first five individuals. I don't mind the residuals etc being written in another file, and not my original dataset, but I want the same type to be written all in one column. Is there a way to do that?

Thank you all for the enlightening discussion and for the loads of help!
Reply | Threaded
Open this post in threaded view
|

Re: Python vs MACRO was: Re: looping, split file and saving

David Marso
Administrator
In reply to this post by xenia
If I stare at R code for any extended period of time I end up with a throbbing headache.
This is even more pronounced when the author elects to be clever and attempts to calculate everything in one line with gobs of nested function calls and no comments ;-)))
OTOH:After the Eureka it is a mildly psychedelic ;-)
I am bRamaged!

xenia wrote
Thank you


On 16 November 2012 12:06, Hart, Kimberly (hartkb) [via SPSSX Discussion] <
[hidden email]> wrote:

>  I am a devoted SPSS user (living in SAS-land) and am new to using R from
> within SPSS, and I love it. There are a few things that I do like R for,
> but I simply hate doing any data management with R. I recommend this
> website: http://r4stats.com/ and the book “R for SAS and SPSS Users: by
> Robert Muenchen. Kim****
>
> ** **
>
> *From:* SPSSX(r) Discussion [mailto:[hidden email]<http://user/SendEmail.jtp?type=node&node=5716256&i=0>]
> *On Behalf Of *xenia
>
> *Sent:* Friday, November 16, 2012 6:45 AM
> *To:* [hidden email]<http://user/SendEmail.jtp?type=node&node=5716256&i=1>
> *Subject:* Re: Python vs MACRO was: Re: looping, split file and saving****
>
> ** **
>
> How can one run R from SPSS?****
>
> ** **
>
> On 16 November 2012 02:28, David Marso [via SPSSX Discussion] <[hidden
> email] <http://user/SendEmail.jtp?type=node&node=5716255&i=0>> wrote:****
>
> The data are very standardized and specific to a very well defined task so
> seriously, that is all that requires specification aside from using one
> name as a proxy for a default field ;-)
> Without violating some NDA I can say the following.
> This project calculates Effect Sizes for some rather special research
> designs (details are confidential) which are input into other macros (some
> of which I wrote last year) for Meta analytic work (so the output is really
> a new data set and nobody really looks at them in a tabular requirement).
> This is part of an ongoing group of research projects with several grants
> and several overlapping teams of prominent researchers and they have worked
> out some pretty nice standards for their data requirements.  I'm on board
> to do the heavy lifting WRT matrix programming and solution development.
>  They do the theory and prototyping in R and then I go to town with SPSS.
> Pretty nice relationship.    I know one can run R from SPSS and they know
> that but they desire/require a native SPSS solution.
>
> If I wanted to create a Pivot TABLE then I could do that with BASIC
> scripting.
>
> But why pray tell would I bother to write a book involving MACRO when it
> is so 20th century (obsolete/deprecated/useless/powerless)?  Why would IBM
> want me to?  Why would I want to jump through all sorts of corporate hoops
> and deal with the suits and the lawyers?  Next thing I know I would be sued
> for reposting my own code on this forum from the book.
> If I were to write a book about SPSS it would be incredibly deep and
> nobody except maybe 10-20 people from this forum would want to (or be able
> to) read it.  Think Hard-Core SPSS (after Bruce McKinney's Hard Core Visual
> Basic).  It would make ?Raynald's?  book look like an introductory guide
> for the slightly perplexed ;-) .  In other words it would have a very
> limited audience and would likely not be of interest to IBM since in my
> opinion they could really care less about advanced user requirements.
> Last year I offered to do a Beta testing for ver 20.  When I asked A.R.
> about a possible free copy for doing a LOT of testing of the more
> exotic/complex features he declined and I mysteriously was 'disappeared'
> from the list of testers.  He didn't even bother to return my email when I
> challenged him.
> OTOH:  If you think such a project would be of interest to the powers that
> be maybe you could champion the idea to appropriate parties?  After all,
> they don't know me from Adam (but you do).
>
>
> ****
>
> *Jon K Peck wrote*
>
>
> Presumably all this computation requires some data, so there must be
> something more to specify.
>
> Another point: if you wanted to present the results in a nice pivot table
> or set of tables, you would need Python in order to generate it (unless
> you could trick an existing procedure into displaying the data nicely).
>
> Maybe you should write a book and apply to the author program for a deal.
> Amazon lists 100 pages of SPSS books, but I don't think that there is a
> single good one on macro.  There are a lot more options than there were
> back at 11.5, too.
>
>
> Jon Peck (no "h") aka Kim
> Senior Software Engineer, IBM
> [hidden email] <http://user/SendEmail.jtp?type=node&node=5716247&i=0>
> new phone: <a href="<a href="tel:720-342-5621">tel:720-342-5621" value="
> +17203425621" target="_blank">720-342-5621
>
>
>
>
> From:   David Marso <[hidden email]<http://user/SendEmail.jtp?type=node&node=5716247&i=1>>
>
> To:     [hidden email]<http://user/SendEmail.jtp?type=node&node=5716247&i=2>,
>
> Date:   11/15/2012 05:49 PM
> Subject:        [SPSSX-L] Python vs MACRO was: Re: looping, split file and
> saving
> Sent by:        "SPSSX(r) Discussion" <[hidden email]<http://user/SendEmail.jtp?type=node&node=5716247&i=3>>
>
>
>
> ****
>
>   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).
> --
>
> Jon K Peck wrote
> > 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] <http://user/SendEmail.jtp?type=node&node=5716256&i=2>
>
> > new phone: <a href="<a href="tel:720-342-5621">tel:720-342-5621" value="
> +17203425621" target="_blank">720-342-5621
> >
> >
> >
> >
> > From:   David Marso < ****
>
> > david.marso@ ****
>
>
> > >
> > To:
>
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=5716256&i=3>
>
> > ,
> > Date:   11/15/2012 02:35 PM
> > Subject:        Re: [SPSSX-L] looping, split file and saving
> > Sent by:        "SPSSX(r) Discussion" < ****
>
>  > [hidden email] <http://user/SendEmail.jtp?type=node&node=5716256&i=4> *
> ***
>
>
> > >
> >
> >
> >
> > 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
> >
> >> [hidden email] <http://user/SendEmail.jtp?type=node&node=5716256&i=5>
> >
> >> new phone: <a href="<a href="tel:720-342-5621">tel:720-342-5621"
> value="+17203425621" target="_blank">720-342-5621
> >>
> >>
> >>
> >>
> >> From:   David Marso <
> > ****
>
>   >> david.marso@ ****
>
> > ****
>
>
> >> >
> >> To:
> >
> >> [hidden email] <http://user/SendEmail.jtp?type=node&node=5716256&i=6>
> >
> >> ,
> >> Date:   11/15/2012 11:49 AM
> >> Subject:        Re: [SPSSX-L] looping, split file and saving
> >> Sent by:        "SPSSX(r) Discussion" <
> > ****
>
>  >> [hidden email] <http://user/SendEmail.jtp?type=node&node=5716256&i=7>
> ****
>
> > ****
>
>
> >> >
> >>
> >>
> >>
> >> "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] <http://user/SendEmail.jtp?type=node&node=5716256&i=8>
> >
> >>  (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] <http://user/SendEmail.jtp?type=node&node=5716256&i=9>
>
> >  (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-tp5715711p5716243.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] <http://user/SendEmail.jtp?type=node&node=5716247&i=4> (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. ** **
>
> ** **
>  ------------------------------
>
> *If you reply to this email, your message will be added to the discussion
> below:*
>
>
> http://spssx-discussion.1045642.n5.nabble.com/looping-split-file-and-saving-tp5715711p5716247.html
> ****
>
> To unsubscribe from looping, split file and saving, click here.
> NAML<http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
> ****
>
> ** **
>
> ** **
>  ------------------------------
>
> View this message in context: Re: Python vs MACRO was: Re: looping, split
> file and saving<http://spssx-discussion.1045642.n5.nabble.com/looping-split-file-and-saving-tp5715711p5716255.html>
>
> Sent from the SPSSX Discussion mailing list archive<http://spssx-discussion.1045642.n5.nabble.com/>at Nabble.com.
> ****
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://spssx-discussion.1045642.n5.nabble.com/looping-split-file-and-saving-tp5715711p5716256.html
>  To unsubscribe from looping, split file and saving, click here<http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5715711&code=ZGltcG9sN0Bnb29nbGVtYWlsLmNvbXw1NzE1NzExfDIyNTUxMjY4Mw==>
> .
> NAML<http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
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?"
Reply | Threaded
Open this post in threaded view
|

Re: looping, split file and saving

David Marso
Administrator
In reply to this post by xenia
This involves running the regression twice, once for presentation purposes -alternating REG-GRAPH-
a second time for resids etc .  NOTE SET RESULTS OFF ERRORS OFF is undocumented technique for suppressing ALL output (came about by my own special request circa SPSS 6.1.4 (about 1996)).
--
CYA using PRESERVE/RESTORE (without that you will be puzzled when you don't get anything coming out for the rest of the day and after calling tech support (and they would *NOT* figure it out) end up pulling out all of your hair, smashing the computer and going on a bender ;-)).

Template:

DEFINE loopit (var !TOKENS(1) /max !TOKENS(1) /more parameters if you want....) .
!DO !codeval=1 !TO !max .
COMPUTE FILT=(!var EQ !codeval ).
FILTER BY FILT.
REG ....(no SAVE here)
GRAPH...
!DOEND
FILTER OFF.
SPLIT FILE BY a_code .
PRESERVE.
SET RESULTS OFF ERRORS OFF.
REG .../SAVE .
RESTORE.
SPLIT FILE OFF.
!ENDDEFINE.

AUTORECODE code / INTO a_code .
SORT CASES BY a_code .
LOOPIT var = a_code max=1000 .



xenia wrote
ok, so got the extra !ENDDEFINE out, the code does what I want, i.e. performs the regression and makes a plot for each individual. However, I do have two problems:
- the list I have to feed in is long. Do I use AUTORECODE (this is what I gather from earlier replies), and where in the code do I use it? is it before declaring the macro?
- with  /SAVE PRED ZPRED ADJPRED SEPRED COOK LEVER RESID ZRESID SRESID DRESID SDRESID in the regression code I save these residuals and distances in my datafile. With SPLIT FILE, the residuals would be written/appended in the same columns at each iteration, now however there are 11 new columns formed with each iteration and the residuals and distances written at the respective rows corresponding to an individual, so in the end I don't have one column for PRED, one column for ZPRED etc but PRED_1, PRED_2,....,PRED_5 e.g. for the first five individuals. I don't mind the residuals etc being written in another file, and not my original dataset, but I want the same type to be written all in one column. Is there a way to do that?

Thank you all for the enlightening discussion and for the loads of help!
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?"
Reply | Threaded
Open this post in threaded view
|

Re: looping, split file and saving

Jon K Peck
SET RESULTS and SET ERRORS are documented in the CSR.  The modern way, which can be more selective, is to use OMS for this sort of thing, but the SET commands do work.


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/16/2012 09:50 AM
Subject:        Re: [SPSSX-L] looping, split file and saving
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




This involves running the regression twice, once for presentation purposes
-alternating REG-GRAPH-
a second time for resids etc .  NOTE SET RESULTS OFF ERRORS OFF is
undocumented technique for suppressing ALL output (came about by my own
special request circa SPSS 6.1.4 (about 1996)).
--
CYA using PRESERVE/RESTORE (without that you will be puzzled when you don't
get anything coming out for the rest of the day and after calling tech
support (and they would *NOT* figure it out) end up pulling out all of your
hair, smashing the computer and going on a bender ;-)).

Template:

DEFINE loopit (var !TOKENS(1) /max !TOKENS(1) /more parameters if you
want....) .
!DO !codeval=1 !TO !max .
COMPUTE FILT=(!var EQ !codeval ).
FILTER BY FILT.
REG ....(no SAVE here)
GRAPH...
!DOEND
FILTER OFF.
SPLIT FILE BY a_code .
PRESERVE.
SET RESULTS OFF ERRORS OFF.
REG .../SAVE .
RESTORE.
SPLIT FILE OFF.
!ENDDEFINE.

AUTORECODE code / INTO a_code .
SORT CASES BY a_code .
LOOPIT var = a_code max=1000 .









Reply | Threaded
Open this post in threaded view
|

Re: looping, split file and saving

David Marso
Administrator
Jon,
  But the combination is crucial.
RESULTS OFF does NOT suppress all output.
Consider:
GET A FILE
PRESERVE.
SET RESULTS OFF ERRORS OFF.
DESC ALL.
RESTORE.
PRESERVE.
SET RESULTS OFF.
DESC ALL.
RESTORE.
PRESERVE.
SET ERRORS OFF.
DESC ALL /STUPID nonexistent subcommand.
RESTORE.
PRESERVE.
DESC ALL /STUPID nonexistent subcommand.
RESTORE.

<TMI>
This was put in by Tex Hull as a quick hack so I could suppress a
200x200 correlation matrix from a client project in 1996.
All I needed was the MATRIX out so I could brutalize it with the
MATRIX language.  There was no way to do so at the time but one Fri
afternoon Tex made my week and saved me a whole lot of hair by adding
that little 'fix'.
Not ALL development was subject to design by committee (once in awhile
us battle weary foot soldiers get a little perk if they know the right
people to talk to! Especially if a $20K deal is riding on getting rid
of a big table)
</TMI>

On Fri, Nov 16, 2012 at 12:35 PM, Jon K Peck <[hidden email]> wrote:

> SET RESULTS and SET ERRORS are documented in the CSR.  The modern way, which
> can be more selective, is to use OMS for this sort of thing, but the SET
> commands do work.
>
>
> 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/16/2012 09:50 AM
> Subject:        Re: [SPSSX-L] looping, split file and saving
> Sent by:        "SPSSX(r) Discussion" <[hidden email]>
> ________________________________
>
>
>
> This involves running the regression twice, once for presentation purposes
> -alternating REG-GRAPH-
> a second time for resids etc .  NOTE SET RESULTS OFF ERRORS OFF is
> undocumented technique for suppressing ALL output (came about by my own
> special request circa SPSS 6.1.4 (about 1996)).
> --
> CYA using PRESERVE/RESTORE (without that you will be puzzled when you don't
> get anything coming out for the rest of the day and after calling tech
> support (and they would *NOT* figure it out) end up pulling out all of your
> hair, smashing the computer and going on a bender ;-)).
>
> Template:
>
> DEFINE loopit (var !TOKENS(1) /max !TOKENS(1) /more parameters if you
> want....) .
> !DO !codeval=1 !TO !max .
> COMPUTE FILT=(!var EQ !codeval ).
> FILTER BY FILT.
> REG ....(no SAVE here)
> GRAPH...
> !DOEND
> FILTER OFF.
> SPLIT FILE BY a_code .
> PRESERVE.
> SET RESULTS OFF ERRORS OFF.
> REG .../SAVE .
> RESTORE.
> SPLIT FILE OFF.
> !ENDDEFINE.
>
> AUTORECODE code / INTO a_code .
> SORT CASES BY a_code .
> LOOPIT var = a_code max=1000 .
>
>
>
>
>
>
>
>
>

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

Re: Python vs MACRO was: Re: looping, split file and saving

Richard Ristow
In reply to this post by Jon K Peck
At 08:12 PM 11/15/2012, Jon K Peck wrote:

>Maybe you should write a book and apply to the
>author program for a deal.  Amazon lists 100
>pages of SPSS books, but I don't think that
>there is a single good one on macro.  There are
>a lot more options than there were back at 11.5, too.

The chapter on macros in the second edition (but
not later editions) of Raynald Levesque's book is
a good place to start, though it'll be a number
of releases behind on macro features: Levesque,
Raynald, *SPSS® Programming and Data Management,
2nd Edition: A Guide for SPSS® and SAS® Users*.
SPSS, Inc., Chicago, 2005. (I have a .pdf; I
don't believe that SPSS still has this edition on-line.)

Contents of chapter 6:
6 Macros
A Very Basic Macro . . . . . . . . . . . . . . . . . . 178
Macro Arguments  . . . . . . . . . . . . . . . . . . . 178
Positional Arguments . . . . . . . . . . . . . . . . . 180
Tokens . . . . . . . . . . . . . . . . . . . . . . . . 181
Conditional Processing . . . . . . . . . . . . . . . . 182
Looping Constructs . . . . . . . . . . . . . . . . . . 184
Macro Expansion. . . . . . . . . . . . . . . . . . . . 188
Doing Arithmetic with Macro Variables  . . . . . . . . 189
Macro Examples . . . . . . . . . . . . . . . . . . . . 190
Importing from MS Access . . . . . . . . . . . . . . . 190
Defining a List of Variables between Two Variables . . 193
Changing Variable Formats  . . . . . . . . . . . . . . 195
Reducing a String to Minimum Length  . . . . . . . . . 198
Including a Procedure in a Loop  . . . . . . . . . . . 201
Counting Distinct Values across Variables  . . . . . . 204
Recursive Macro (Macro Calling Itself) . . . . . . . . 206
Random Samples and Selections  . . . . . . . . . . . . 208
Generating Simulated Data  . . . . . . . . . . . . . . 217
Working with Many Files  . . . . . . . . . . . . . . . 219
Finding All Combinations of Three Letters Out of N . . 225
Creating Variables Containing Bounds of the CI for the Mean. 228
Debugging Macros . . . . . . . . . . . . . . . . . . . 232
Printback of the Expanded Syntax . . . . . . . . . . . 232
Print Arguments  . . . . . . . . . . . . . . . . . . . 232
Examples of Error Messages . . . . . . . . . . . . . . 233
Other Macro Examples Included with SPSS. . . . . . . . 236

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Python vs MACRO was: Re: looping, split file and saving

Richard Ristow
In reply to this post by Ruben Geert van den Berg
At 04:59 AM 11/16/2012, Ruben van den Berg wrote:

>IMHO, one of the (many) great features of Python is that it can save
>you from a lot of manual typing by simply retrieving things like
>variable names, file names, excel sheet names (and so on) from the data.

Point definitely taken. Python is excellent for this for a pair of
reasons: (1) It has direct access to the data dictionary; (2) It does
meta-programming (generating code based on data) gracefully, via
Python's native functions plus SPSS.SUBMIT.

However,

>When it comes to defining and using lists of variables, I really
>like to use the "TO" keyword ("var_a var_b var_e TO var_h var_m").
>Python handles this flawlessly but how can I use this list in a
>macro? And what if there are many (say, 100) variables between
>"var_e" and "var_h"?

I don't know your specific problems; but, as others have pointed out,
a lot of these effects can be got handily using DO REPEAT.

The Python-SPSS connection is a great step, but I wouldn't want to
have us forget just how much the native SPSS syntax can do.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Python vs MACRO was: Re: looping, split file and saving

David Marso
Administrator
In reply to this post by Richard Ristow
"The chapter on macros in the second edition (but
not later editions) of Raynald Levesque's book is
a good place to start, though it'll be a number
of releases behind on macro features"

It is still up on Raynald's site: http://www.spsstools.net/spss_programming.htm
However,  I don't believe macro has changed wrt features since prior to 1990.
There was a simple fix in 6.1.4 (which took me 2+ years of pressure on development to implement) for a weird phantom space insertion phenomenon but other than that I cannot think of any added features to the macro language.
Interesting that none of the Programming and data management books after 2nd ed. even mention macro, also there seems to be no mention of the built in Basic scripting or running from .NET or VBA .
Looks like the python camp has been quite efficient in removing all traces of former folly?--
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?"
123