When you use a macro, the macro first 'inflates' the actual syntax within the macro and then executes the commands (as far as I understand). For example, if a macro shall execute a set of commands repeatedly, the whole syntax is first 'inflated' and then executed. This may lead to a long time between calling the macro and executing it. Now, is there a 'workaround' if you have to repeat a makro (that you can't change) for let's say millions of times (which could lead to a standstill) ? Maybe with python (?)
Thanks
Dr. Frank Gaeth
|
I believe using a macro or python is valuable when you want to do the
same procedure with systematic variation in parts of the commands. They are more likely to be useful in a data processing environment than in a data analysis environment. If I understand correctly, there are few things that can be done with macros that cannot be done in Python. Whereas there are many things that can be done with python but not with macros. <don protective anti-flame gear> New data processing procedures should not use macros. They are obsolete. The only reason to use them is to save time writing due to lack of knowledge of Python. <remove protective anti-flame gear> One approach. Before we had macros and python we would write syntax using strings as the stand-in variables. Then we would use a text editor to globally replace those strings and concatenate the sets of syntax. Macros, IIRC, grew out of that approach. If you expand a macro and print it that is very much what macros do. If you only need to expand the syntax once, would it help to expand the macro and cut-and-paste from the output file to a new syntax file. It seems that the time to expand the macro would be a result of how many different new sets it needs to generate. Another approach. SPLIT FILE can be used in some circumstances. Another approach. Do many variables on a pass and cut-and-paste from the output. Perhaps if you describe what you would like to do in more detail, members on this list who are more fluent in macros and python could offer more concrete suggestions. Art Kendall Social Research Consultants On 4/17/2011 2:38 AM, drfg2008 wrote: > When you use a macro, the macro first 'inflates' the actual syntax within the > macro and then executes the commands (as far as I understand). For example, > if a macro shall execute a set of commands repeatedly, the whole syntax is > first 'inflated' and then executed. This may lead to a long time between > calling the macro and executing it. Now, is there a 'workaround' if you have > to repeat a makro (that you can't change) for let's say millions of times > (which could lead to a standstill) ? Maybe with python (?) > > Thanks > > ----- > Dr. Frank Gaeth > FU Berlin > > -- > View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SPSS-Macro-tp4308532p4308532.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD > ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Art Kendall
Social Research Consultants |
Thanks!
Well, we already have plenty of (pretty complex) macros. I don't want to rewrite these macros in python. Too much time is needed for that job. However, since our data is increasing, there will be a natural end to it soon. That's why I'm interested in finding a solution with macros (plus python if necessary/possible). Frank
Dr. Frank Gaeth
|
You should not worry about the time required
to expand a macro. It will be trivial compared to the time required
to execute the generated syntax. But the more complex the macro,
the better the case for replacing it with Python - not to save time but
to simplify writing and maintenance. That's something you can do
incrementally, though. And bear in mind that Python programs can
even generate macro definitions via the spss.SetMacroValue api.
Regards, Jon Peck Senior Software Engineer, IBM [hidden email] 312-651-3435 From: drfg2008 <[hidden email]> To: [hidden email] Date: 04/17/2011 06:10 AM Subject: Re: [SPSSX-L] SPSS Macro Sent by: "SPSSX(r) Discussion" <[hidden email]> Thanks! Well, we already have plenty of (pretty complex) macros. I don't want to rewrite these macros in python. Too much time is needed for that job. However, since our data is increasing, there will be a natural end to it soon. That's why I'm interested in finding a solution with macros (plus python if necessary/possible). Frank ----- Dr. Frank Gaeth FU Berlin -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SPSS-Macro-tp4308532p4308817.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 |
You should not worry about the time required to expand a macro. It will be trivial compared to the time required to execute the generated syntax.
Well not for Montecarlo trials with hundreds of thousands of runs. Python will be the better option. Thanks
Dr. Frank Gaeth
|
In reply to this post by drfg2008
At 01:38 AM 4/17/2011, drfg2008 wrote:
>When you use a macro, the macro first 'inflates' ["expands" is the >preferred term] the actual syntax within the macro and then executes >the commands (as far as I understand). If a macro shall execute a >set of commands repeatedly, the whole syntax is first 'inflated' and >then executed. Actually, when the SPSS program is loaded, all macros are expanded ('inflated'); when the program is running, all macros have disappeared and been replaced by the SPSS commands they expand into. >This may lead to a long time between calling the macro and executing >[its code]. Yes, though I don't see any difficulties that would create. >Now, is there a 'workaround' if you have to repeat a macro (that you >can't change) for let's say millions of times (which could lead to a >standstill)? Can you give us some idea where this would come up? Would you really need essentially the same code (generated by the same macro) millions of times in the same SPSS program? Or am I missing what you mean? -Best wishes, Richard ===================== 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 |
Hi,
I will be out of the office till Monday, 4/25/11. I will reply to your email on Monday.
Thank you.
Joanne Han Marketing Research Manager UCLA Extension
|
Free forum by Nabble | Edit this page |