ReHow to replace non-missing duplicate responses in Multiple Response sets?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ReHow to replace non-missing duplicate responses in Multiple Response sets?

Art Kendall
Once again I am trying to avoid re-inventing the wheel. Has anybody already
worked this out?

For each response in a list after the first with a positive value, look back
to see if any previous value has the same positive value. If it IS a match,
replace it with -2. Else, leave it alone.

I have multiple-response sets. When a response with a positive value is
mentioned again I would like to replace its value with a specific missing
value. It is valid
The example below only has 3 in a set, but I am looking for something more
general up to a dozen or so responses in a set. and 40 or more specific
values that could be mentioned.

Snack1 to Snack3 are the responses
Want1 to Want3 are what I would like to end up with.
Cases 06 to 08 would have different values after the transformations.

* Name up to 3 snacks you had today."
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 'Cherries'
    3 'Orange'
    -3 'No response for any snack'
    -2 'duplicate of earlier response'
    -1 'fewer responses in Multiple Response'.
list.



-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: ReHow to replace non-missing duplicate responses in Multiple Response sets?

Jon Peck
The Want variables seem to exist in the input, so I'm not clear how the data are processed.

p.s.  CTABLES has an option about whether or not to count duplicates in MR sets, so I think it would take care of the issue in that context.

On Sun, May 2, 2021 at 1:33 PM Art Kendall <[hidden email]> wrote:
Once again I am trying to avoid re-inventing the wheel. Has anybody already
worked this out?

For each response in a list after the first with a positive value, look back
to see if any previous value has the same positive value. If it IS a match,
replace it with -2. Else, leave it alone.

I have multiple-response sets. When a response with a positive value is
mentioned again I would like to replace its value with a specific missing
value. It is valid
The example below only has 3 in a set, but I am looking for something more
general up to a dozen or so responses in a set. and 40 or more specific
values that could be mentioned.

Snack1 to Snack3 are the responses
Want1 to Want3 are what I would like to end up with.
Cases 06 to 08 would have different values after the transformations.

* Name up to 3 snacks you had today."
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 'Cherries'
    3 'Orange'
    -3 'No response for any snack'
    -2 'duplicate of earlier response'
    -1 'fewer responses in Multiple Response'.
list.



-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: ReHow to replace non-missing duplicate responses in Multiple Response sets?

Art Kendall
Thank you.

Once again I was unclear.  The "Want" variables were just figured out in my
head.

I'll look at the CTABLES approach.

For the archives.
This demo works.  I suggest transforming into new variables until you check
that it worked in your instance.
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.
* remember to APPLY DICTIONARY.



-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants