Respondents assessing different services - duplicates

Discussion in 'SPSS' started by TorsteinJ, Nov 3, 2011.

  1. TorsteinJ

    TorsteinJ Guest

    Dear all,

    I am trying to figure out a way to do a thing.

    I have a dataset in which several people have been asked background
    information, and thereafter have been asked to assess between 0 and 6
    services. I would now like to organize the data in such an order that
    indivual persons (identified with individual respondent IDs) and their
    background information is duplicated (n+1) times, where n is the
    number of services the respondent has assessed. But for each case, it
    should contain only the assessment of one of the 0 to 6 services that
    the respondent has assessed (the total number of services being
    assessed is 23).

    My dataset looks like this:
    id age gender serv1_1 serv1_2 serv2_1 serv2_2 serv3-1 serv3_2
    1 20 1 2 3 1 2
    1 20 1 2 3 1 2
    2 50 2 5 4 7 6 4 1
    2 50 2 5 4 7 6 4 1
    2 50 2 5 4 7 6 4 1
    3 60 2
    4 40 1 3 2

    While it should look like this:
    My dataset looks like this:
    id age gender serv1_1 serv1_2 serv2_1 serv2_2 serv3-1 serv3_2
    1 20 1 2 3
    1 20 1 1 2
    2 50 2 5 4
    2 50 2 7 6
    2 50 2 4 1
    3 60 2
    4 40 1 3 2

    Hope some of you have got a good clue as to how to do this!

    Best regards,
    Torstein
     
    TorsteinJ, Nov 3, 2011
    #1
    1. Advertisements

  2. TorsteinJ

    TorsteinJ Guest

    Let me try again...

    My dataset looks like this:
    id age gender serv1_1 serv1_2 serv2_1 serv2_2 serv3-1
    serv3_2
    1 20 1 2 3 1 2
    1 20 1 2 3 1 2
    2 50 2 5 4 7 6 4 1
    2 50 2 5 4 7 6 4 1
    2 50 2 5 4 7 6 4 1
    3 60 2
    4 40 1 3 2

    While it should look like this:
    My dataset looks like this:
    id age gender serv1_1 serv1_2 serv2_1 serv2_2 serv3-1
    serv3_2
    1 20 1 2 3
    1 20 1 1 2
    2 50 2 5 4
    2 50 2 7 6
    2 50 2 4 1
    3 60 2
    4 40 1 3 2
    Hope this looks better!
     
    TorsteinJ, Nov 3, 2011
    #2
    1. Advertisements

  3. TorsteinJ

    Rich Ulrich Guest

    Your file example, above, already shows multiple rows for each
    ID, and they are exact duplicates. Your first step might thus be,
    REMOVE the duplicates. SPSS has a feature for that.

    If you want the "weight" of each person depending on how many
    entries there are, you can use COUNT to get the number of
    services for a person.
    Well, that seems totally useless. I can't imagine what *good*
    purpose you serve by doing that to your file.

    The reasonable conversion from "wide" to "long" is available as
    VarsToCases. That gives each record a sequential identifier, which
    seems adequate.


    Do you really have a purpose for writing out a varying number
    of lines per ID? You could do that with a LOOP, using XSAVE inside
    the Loop. Or go back to the version of the file with duplications
    already, and zap some to zero. Either way gets too messy for
    me to bother with, unless there is some good reason.
     
    Rich Ulrich, Nov 3, 2011
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.