Problem computing an ID variable

Discussion in 'SPSS' started by Chris, Nov 19, 2011.

  1. Chris

    Chris Guest

    Hi all,

    I want do compute an ID variable that is incremented by 1 every 3
    casenum. I can do it with the lag function if it is a simple count
    (1,2,3,4, etc.) but how can I do it if I want it to look like this:

    ID
    1
    1
    1
    2
    2
    2
    3
    3
    3
    and so on

    Thank you

    Christian
     
    Chris, Nov 19, 2011
    #1
    1. Advertisements

  2. Chris

    Rich Ulrich Guest

    Having achieved a simple count as IDTEMP, or $Casenum,
    you can

    Compute ID3= trunc( (IDTEMP+2)/3 ).

    It is also possible to use the lag function to look at
    the value of 2 and 3 rows previous, in addition to the
    first lag. But that doesn't seem needed here.
     
    Rich Ulrich, Nov 19, 2011
    #2
    1. Advertisements

  3. Chris

    Chris Guest

    Thank you. Simpler than i thought. I was thinking too much, too far
    away.

    Christian
     
    Chris, Nov 20, 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.