Hi,
To speed up production runs of a lengthy procedure, I'd like to be able to turn off some/all of the diagnostic output (from FREQ, CROSSTABS, etc.) My thought was to define a macro value and surround the diagnostic output syntax with something like a DO IF, as shown below. DEFINE mDiagnostic() 1 !ENDDEFINE. DO IF (mDiagnostic > 0). FREQUENCIES VARIABLES=Promotion /ORDER=ANALYSIS. END IF. This doesn't work, however, since (my understanding of the manual) FREQ is not a "transformation" command. Suggestions? Thanks! -Tim ===================== 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 |
Procedures cannot be executed in transformation
loops, since they are iterated casewise. What you want to do is a
common use of Python programmability.
For example, begin program. import spss mDiagnostic = 1 end program. ... lots of SPSS syntax ... begin program. if mDiagnostic == 1: spss.Submit(r""" FREQUENCIES VARIABLES=Promotion /ORDER=ANALYSIS.""") end program. ... etc Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Tim Graettinger <[hidden email]> To: [hidden email], Date: 11/18/2013 11:34 AM Subject: [SPSSX-L] Turn diagnostic output (FREQS, CROSSTABS) on/off Sent by: "SPSSX(r) Discussion" <[hidden email]> Hi, To speed up production runs of a lengthy procedure, I'd like to be able to turn off some/all of the diagnostic output (from FREQ, CROSSTABS, etc.) My thought was to define a macro value and surround the diagnostic output syntax with something like a DO IF, as shown below. DEFINE mDiagnostic() 1 !ENDDEFINE. DO IF (mDiagnostic > 0). FREQUENCIES VARIABLES=Promotion /ORDER=ANALYSIS. END IF. This doesn't work, however, since (my understanding of the manual) FREQ is not a "transformation" command. Suggestions? Thanks! -Tim ===================== 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 |
Dumb question perhaps, but what exactly is meant by "diagnostic output"?
|
Administrator
|
I was wondering about that too after my first reading the OP. I first understood Tim to be saying that he wanted to run commands such as FREQUENCIES and CROSSTABS, but to turn off certain (diagnostic) parts of the output from them. But looking at the example he gave, I eventually decided he meant something like this: During development of syntax, he is including frequency distributions and crosstabs (etc) at various places to check on various things. But once the syntax is fully developed, he wants to run the syntax with those "diagnostic" procedures excluded.
HTH.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Administrator
|
In reply to this post by Tim Graettinger
Wrap the whole thing in a parameterized macro and pass a parameter.
See the canonical correlations and Ridge Regression macros for an example. eg DEFINE myjunk (!POS !CMDEND !DEFAULT (N)). !IF (!1!NE N) !THEN PRESERVE. SET ERRORS OFF RESULTS OFF . XTABS or FREQS or whatever you are calling Diagnostic.... RESTORE . !IFEND ... regular code here... --- !ENDDEFINE . call using MYJUNK . or to get diagnostics.. MYJUNK @ . If this makes no sense then look at the DEFINE !ENDDEFINE section of the FM. you should do that anyway to grok the difference between !IF and IF. Alternatively look at OMS to see that one can have select output NOT show up in the viewer. You'll still need a macro wrapper or get dirty with python ;-(
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by Bruce Weaver
Using INSERT, in one way or another, is how I can think of having a
procedure as optional. Here is a way to turn on/off some optional procedures. Create a directory that holds separate, small .SPS files for each of the diagnostics, and INSERT them at the places that are needed. Then create another directory with the same file names, but where each file includes nothing except maybe a comment like "Dummy Insert". The diagnostics could be turned off in either of two ways. (1) In the main code, change the File Handle or Macro that holds the directory name so that it points to the Dummy directory. (2) Copy the DUMMY versions on top of the DIAGNOSTIC versions. [ Turn back on by restoring from Backup.] This option potentially allows separate decisions for any individual tests to be Inserted. -- Rich Ulrich > Date: Mon, 18 Nov 2013 12:27:45 -0800 > From: [hidden email] > Subject: Re: Turn diagnostic output (FREQS, CROSSTABS) on/off > To: [hidden email] > > I was wondering about that too after my first reading the OP. I first > understood Tim to be saying that he wanted to run commands such as > FREQUENCIES and CROSSTABS, but to turn off certain (diagnostic) parts of the > output from them. But looking at the example he gave, I eventually decided > he meant something like this: During development of syntax, he is including > frequency distributions and crosstabs (etc) at various places to check on > various things. But once the syntax is fully developed, he wants to run the > syntax with those "diagnostic" procedures excluded. > > HTH. > > > > > Ruben Geert van den Berg wrote > > Dumb question perhaps, but what exactly is meant by "diagnostic output"? > > > ... |
In reply to this post by Tim Graettinger
Thanks all for the comments and ideas - and thanks to Bruce for explaining
accurately what I meant by my vague use of the term "diagnostic output". I should have mentioned that I'd prefer to use just SPSS Base for the solution. I'm handling the code off to a client who has Base installed, but for whom it might be asking a lot to install Python and the extensions, etc. So, I'll be trying out the approaches sketched by David and Rich. Thanks again! -Tim ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
How about a hybrid of Rich's and my thoughts?
/** This macro could be INSERT-ed from an external file **/. DEFINE DIAGNOSTICS (!POS !CMDEND) . !IF (!EVAL(DEBUG) !EQ Y) !THEN FREQ !1. !IFEND . !ENDDEFINE . /** Place this at the top of your syntax file (or anywhere prior to calling DIAGNOSTICS **/. /** Comment/Uncomment one of these lines depending upon debug status **/. DEFINE DEBUG () @ !ENDDEFINE . DEFINE DEBUG () Y !ENDDEFINE . /** main code **/. DATA LIST free / a b c. BEGIN DATA 1 2 3 1 2 3 4 5 6 7 8 9 END DATA. list. COMPUTE d=a*b. DIAGNOSTICS a b d.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
Ah, right...!EVAL. I briefly played around with an idea similar to this yesterday, but couldn't get it to work, because I couldn't remember the name of the function to make a macro expand. I was thinking it was something like !EXPAND, and got distracted by !NOEXPAND, !ONEXPAND and !OFFEXPAND.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Administrator
|
I don't think anyone would ever accuse the former SPSS inc. of over documenting DEFINE !ENDDDEFINE.
The same sad 3 appendix examples have been in the FM for decades. One could probably mine my postings in this group for a month and find better examples than what is in the FM. The only way I mastered macro was by playing with it over and over again. Making a lot of stupid mistakes, Doh: Facepalm... The only info on !EVAL in the FM is this barely comprehensible paragraph. !EVAL (str). Scan the argument for macro calls. During macro definition, an argument to a function or an operand in an expression is not scanned for possible macro calls unless the !EVAL function is used. It returns a string that is the expansion of its argument. For example, if mac1 is a macro, then !EVAL(mac1) returns the expansion of mac1. If mac1 is not a macro, !EVAL(mac1) returns mac1. No examples, no reason really of why anyone should care. My typical MO is if the damn thing doesn't work as initially expected then toss in an !EVAL ;-) One current show stopper is trying to use the new graphics in a macro. What a total crock. The pythgonistas would love to bury macro in a deep hole, give it a dirt nap, forget it exists.. Maybe another day or 2 of programming effort back in the late 80's would have made it a solid beast?
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
In reply to this post by David Marso
In FORTRAN on DEC-10s there
was a compile time switch /debug.
if the switch was on code lines hat had a D in column 1 were compiled, loaded, and executed. If it was off... Art Kendall Social Research ConsultantsOn 11/19/2013 9:29 AM, David Marso [via SPSSX Discussion] wrote: How about a hybrid of Rich's and my thoughts?
Art Kendall
Social Research Consultants |
In reply to this post by Tim Graettinger
Pretty cool, David. I'm thinking that I'll create little macro "wrappers"
as you show below for each of my favorite diagnostics (freqs w/ histogram, freqs w/ bar chart, crosstab w/ row totals, etc.). Then, they can function as a little library of diagnostics that can be turned on/off at will based on the value of the DEBUG macro variable. -Tim On Tue, 19 Nov 2013 06:29:29 -0800, David Marso <[hidden email]> wrote: >How about a hybrid of Rich's and my thoughts? >/** This macro could be INSERT-ed from an external file **/. >DEFINE DIAGNOSTICS (!POS !CMDEND) . >!IF (!EVAL(DEBUG) !EQ Y) !THEN >FREQ !1. >!IFEND . >!ENDDEFINE . > >/** Place this at the top of your syntax file (or anywhere prior to calling >DIAGNOSTICS **/. >/** Comment/Uncomment *one * of these lines depending upon debug status **/. >DEFINE DEBUG () @ !ENDDEFINE . >DEFINE DEBUG () Y !ENDDEFINE . > >/** main code **/. >DATA LIST free / a b c. >BEGIN DATA >1 2 3 1 2 3 4 5 6 7 8 9 >END DATA. >list. >COMPUTE d=a*b. >DIAGNOSTICS a b d. > > >Tim Graettinger wrote >> Thanks all for the comments and ideas - and thanks to Bruce for explaining >> accurately what I meant by my vague use of the term "diagnostic output". >> >> I should have mentioned that I'd prefer to use just SPSS Base for the >> solution. I'm handling the code off to a client who has Base installed, >> but >> for whom it might be asking a lot to install Python and the extensions, >> etc. >> So, I'll be trying out the approaches sketched by David and Rich. Thanks >> again! >> -Tim >> >> ===================== >> 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. >--- >"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos >Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" >-- >View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Turn-diagnostic-output-FREQS-CROSSTABS-on-off-tp5723130p5723150.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 |
It might take less of
your time to install python etc for your client, than to write
custom wrappers.
Especially if the client is upgrading Base. ---- If you want to use only part of an output file to send to somebody else you might consider using in your blocks of syntax OMS commands. using tags from the index pane in the viewer and / or <edit> <option> <viewer> setting for pseudo users on the clients system and /or SET for errors messages odisplay an/or PRESERVE. ... RESTORE. Art Kendall Social Research ConsultantsOn 11/20/2013 8:33 AM, Tim Graettinger [via SPSSX Discussion] wrote: Pretty cool, David. I'm thinking that I'll create little macro "wrappers"
Art Kendall
Social Research Consultants |
Another option:
define !debug () "True" !enddefine. /** may be INSERTed **/. begin program. import spss, spssaux, sys def diagnostic(): spss.Submit("datafile attribute attribute = debug(!debug).") debug = eval(spssaux.getAttributesDict()["debug"].title()) if debug: crap = map(spss.Submit, sys.argv[1:]) end program. /** main code **/. data list free / a b c. begin data 1 2 3 1 2 3 4 5 6 7 8 9 end data. compute d = a*b. /** commands here are conditionally called, depending on debug value /**. spssinc program diagnostic "frequencies a b c" "crosstabs a by b / cells = count". Regards, Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -------------------------------------------- On Wed, 11/20/13, Art Kendall <[hidden email]> wrote: Subject: Re: [SPSSX-L] Turn diagnostic output (FREQS, CROSSTABS) on/off To: [hidden email] Date: Wednesday, November 20, 2013, 3:06 PM It might take less of your time to install python etc for your client, than to write custom wrappers. Especially if the client is upgrading Base. ---- If you want to use only part of an output file to send to somebody else you might consider using in your blocks of syntax OMS commands. using tags from the index pane in the viewer and / or <edit> <option> <viewer> setting for pseudo users on the clients system and /or SET for errors messages odisplay an/or PRESERVE. ... RESTORE. Art Kendall Social Research Consultants On 11/20/2013 8:33 AM, Tim Graettinger [via SPSSX Discussion] wrote: Pretty cool, David. I'm thinking that I'll create little macro "wrappers" as you show below for each of my favorite diagnostics (freqs w/ histogram, freqs w/ bar chart, crosstab w/ row totals, etc.). Then, they can function as a little library of diagnostics that can be turned on/off at will based on the value of the DEBUG macro variable. -Tim On Tue, 19 Nov 2013 06:29:29 -0800, David Marso <[hidden email]> wrote: >How about a hybrid of Rich's and my thoughts? >/** This macro could be INSERT-ed from an external file **/. >DEFINE DIAGNOSTICS (!POS !CMDEND) . >!IF (!EVAL(DEBUG) !EQ Y) !THEN >FREQ !1. >!IFEND . >!ENDDEFINE . > >/** Place this at the top of your syntax file (or anywhere prior to calling >DIAGNOSTICS **/. >/** Comment/Uncomment *one * of these lines depending upon debug status **/. >DEFINE DEBUG () @ !ENDDEFINE . >DEFINE DEBUG () Y !ENDDEFINE . > >/** main code **/. >DATA LIST free / a b c. >BEGIN DATA >1 2 3 1 2 3 4 5 6 7 8 9 >END DATA. >list. >COMPUTE d=a*b. >DIAGNOSTICS a b d. > > >Tim Graettinger wrote >> Thanks all for the comments and ideas - and thanks to Bruce for explaining >> accurately what I meant by my vague use of the term "diagnostic output". >> >> I should have mentioned that I'd prefer to use just SPSS Base for the >> solution. I'm handling the code off to a client who has Base installed, >> but >> for whom it might be asking a lot to install Python and the extensions, >> etc. >> So, I'll be trying out the approaches sketched by David and Rich. Thanks >> again! >> -Tim >> >> ===================== >> 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?" >-- >View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Turn-diagnostic-output-FREQS-CROSSTABS-on-off-tp5723130p5723150.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 If you reply to this email, your message will be added to the discussion below: http://spssx-discussion.1045642.n5.nabble.com/Turn-diagnostic-output-FREQS-CROSSTABS-on-off-tp5723130p5723190.html To start a new topic under SPSSX Discussion, email [hidden email] To unsubscribe from SPSSX Discussion, click here. NAML Art Kendall Social Research Consultants View this message in context: Re: Turn diagnostic output (FREQS, CROSSTABS) on/off 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 |
Free forum by Nabble | Edit this page |