Re: Help with macros

Posted by Art Kendall on
URL: http://spssx-discussion.165.s1.nabble.com/Help-with-macros-tp5740865p5740868.html

Your variable names do not appear to be very Mnemonic.
CTABLES has a built in option to ignore duplicates.

Unless you have many multiple response sets and or expect to do this task you do not need to use macros.  For many such tasks, Python may be more useful than macros.

Try this exercise in un-duplicating multiple response sets.
where Snack(i) is a multiple response set and Want(i) is the intended result.
does Result(i) match Want(i)?

Multiple response sets can have particular kinds of missing data. Here all negative values are meant to be user missing.

new file.
data list list/HH (f2)Snack1 to Snack3 (3f2) Want1 to Want3 (3f2).
begin data
    01 1 2 3 1 2 3
    02 3 2 1 3 2 1
    03 1 3 2 1 3 2
    04 1 3 -1 1 3 -1
    05 1 -1 -1 1 -1 -1
    06 1 1 1 1 -2 -2
    07 1 2 2 1 2 -2
    08 1 2 1 1 2 -2
    09 -3 -3 -3 -3 -3 -3
end data.
*MISSING VALUES Snack1 to Want3 (LO THRU -1).
VALUE LABELS Snack1 to Want3
    1 'Apple'
    2 'Cherry'
    3 'Lemon'
    -3 'No response for any snack'
    -2 'duplicate of earlier response'
    -1 'fewer responses in Multiple Response'.
list.
VECTOR S=Snack1 to Snack3.
VECTOR Result(3).
VECTOR R= Result1 to Result3.
LOOP #I =1 to 3.
    COMPUTE R(#I) = S(#I).
    DO IF #I GT 1.
        LOOP #J = 1 to #I-1.
            IF R(#I) EQ R(#J) R(#I) = -2.
        END LOOP.
    END IF.
END LOOP.
LIST.


Is this the kind of thing you are trying to do?
Art Kendall
Social Research Consultants