Assigning "Counter" for Groups

P

poleenie

I have a dataset like this:

ID Date
10 1/2/2009
10 1/2/2009
10 1/2/2009
11 2/3/2009
11 2/3/2009
11 4/5/2009
11 4/5/2009
12 5/5/2009
12 5/5/2009
12 6/6/2009

Basically, there can be multiple dates for each. How do I group them
based on ID and and groups of different dates to create a new variable
called DateGroup?

ID Date DateGroup
10 1/2/2009 1
10 1/2/2009 1
10 1/2/2009 1
11 2/3/2009 1
11 2/3/2009 1
11 4/5/2009 2
11 4/5/2009 2
12 5/5/2009 1
12 5/5/2009 1
12 6/6/2009 2

Any help would be appreciated!!

Pauline
 
P

poleenie

Sorry for the confusion. I'm counting within the same ID, so the
counter resets itself when there is a new ID. It will stay the same if
the date is the same (within ID).
 
D

Dave Peterson

With your data in A2:Bxxx (headers in row 1),

try this in C2:
=IF(A2<>A1,1,IF(B2=B1,C1,C1+1))

(and drag down as far as you need)

This does assume that your data is sorted nicely.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top