Re: do repeat

Posted by Art Kendall on
URL: http://spssx-discussion.165.s1.nabble.com/do-repeat-tp5719707p5719736.html

I admit it is a soapbox topic.  

You surely are not a beginner and despite having used SPSS since 1972 I still learn from your posts.  However, people who follow  the list or search the archives are at least to some degree learners.

To aid debugging and for quality assurance review I try to have people catch all instances of sysmis, redraft the syntax,  and provide for that condition in the transformations.  Then assign a missing value that can be labelled.
Redrafting would not be finished until all sysmis had been changed to to user missing with value labels
for example in this instance I would put
value labels varlist -999 'missing to avoid dividing by zero' .


Art Kendall
Social Research Consultants
On 4/25/2013 1:47 PM, David Marso [via SPSSX Discussion] wrote:
In principle I agree with the sysmis on right side for the most part.
However in this case it is a direct correlate to the notion that the SYSTEM could NOT carry out some operation namely an attempted division by 0 (which would indeed end up as SYSMIS in normal calculations after spewing a host of warning messages.  Protecting the division with DO IF will render the same result.  So, my using SYSMIS in this case is deliberate and significant in reflecting the inability of the system to caary out the computation.
--
In MATRIX such an misadventure results in a fatal untrappable error and SPSS takes its ball and goes home (end of game), leading to unhappy emails and or phone calls.  

My shameless hack attempts to capitalize on the cranked up energizer bunny properties of MATRIX vector efficiency while gracefully avoiding division by 0.  It is crucial to mop up afterwards internally to avoid ludicrous results but it is easier than protecting EVERY DIVISION in MATRIX with the following awkward monstrosity.

DO IF (zero_check_matrix).
COMPUTE newarray = oldarray / value.
ELSE.
COMPUTE newarray=MAKE(NROW(oldarray),NCOL(oldArray),0).
LOOP #=1 TO NROW(oldarray).
LOOP ##=1 TO NCOL(oldArray).
COMPUTE newarray(#,##)=oldarray(#,##)/value.
END LOOP.
END LOOP.
END IF.

This also ends up being a PITA because one must take great care to treat the resulting 0 appropriately in subsequent calculations.  In the HACK mode one can test for HUGE values which are distinguishable from 0's which can legitimately arise from 0 numerators .
Yeah, there are trade offs, and I am nowhere near solving every weird thing that can crop up in complex situations.
But, I do stand by my using SYSMIS for this situation ;-)
--
Art Kendall wrote
OOPS! sysmis on right side of
      assignment operator.
      RECODE ALL  (LO THRU 1.0 = COPY)
     
                   (ELSE    -999    = ).
     
      missing values all (-999).
      Art Kendall
Social Research Consultants
      On 4/25/2013 12:15 PM, Richard Ristow [via SPSSX Discussion]
      wrote:
   
     At 09:43 AM 4/25/2013, David Marso wrote:
     
     
      >If the numbers are all positive then you can nuke the very
      small fudge factor
     
      >and remove the recode.
     
      >If you have negative values then you will need to modify the
      recode (I'm
     
      >sure you can sort that).
     
     
      >RECODE ALL (1.000001 THRU HI=SYSMIS).
     
     
      I think a cleaner way to do this RECODE, sidestepping having to
     
      choose a fudge factor, is
     
     
      RECODE ALL  (LO THRU 1.0 = COPY)
     
                   (ELSE        = SYSMIS).
     
     
      But actually, I think the dividing-by-zero problem is a strong
      reason
     
      to do the computation in a transformation program, rather than
      MATRIX.
     
     
      =====================
     
      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/do-repeat-tp5719707p5719720.html 
     
     
        To start a new topic under SPSSX Discussion, email
        [hidden email] 
        To unsubscribe from SPSSX Discussion, click
          here .
        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?"



If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/do-repeat-tp5719707p5719723.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