03-03-2015 04:48 PM
How do I create a counter that will roll through the sorted data set and count the number of occurrences of one record and assign that value in a variable? I have to count the number of times a record had a call in a given day.
03-03-2015 06:35 PM
An easy but slow way is to (re)sort your data by id (record identifier) and date-time. Then use a data step, that initializes the counter at each ID group start (and at each day start if you have more days in the data) and then simply increment that counter at each observation. Then you can (back)sort your data by date-time if needed.
Another approach, if your data is already sorted by date-time (and you don't want to re-sort), to use a hash object that holds the counter for each id.