Re: do repeat
Posted by
David Marso on
URL: http://spssx-discussion.165.s1.nabble.com/do-repeat-tp5719707p5719721.html
Thank You for that Richard,
I like your mop up much better than mine.
using the Transformation program one would:
DO REPEAT v= list1 / w=list2.
DO IF (v NE 0).
COMPUTE w=1/v.
END IF.
END REPEAT.
---
I suppose my MATRIX hack is a little unorthodox but by choosing an INFINITESIMAL
term to add to the vector I don't need to explicitly check and it comes back into SPSS with a fudge factor which can not be detected in the precision available to the main system.
AND it SLAMS it all through with one line of clever code.
MATRIX is a cranked up energizer bunny when it comes down to performance!!!
It truly excels at vector based operations but is a little slow with item by item looping.
Now, I have no idea how MATRIX can represent such very small values and avoid the zero divide infinity.
But, AFAICT it works like a charm. The only mop up required are the HUGE lingering values which require a RECODE or other technique to remove.
If there is a downside to this I would be most interested in your analysis and counterexamples.
Richard Ristow 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
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?"