Hi, I have a dataset looks like below: ID Visit CurrentTotal 1 0 0 1 0 1 1 1 0 1 0 3 1 1 2 1 1 1 1 1 0 For the same ID, there are three parts of data - the observations in black, red and blue. For each part, I need to count the total number of visits. Right now, the CurrentTotal variable is displayed in the dataset, which is not correct for the counts of each part (black, red and blue). What I would like to ask is that "How to add a variable "TargetTotal" as shown below to have the correct number of visit count for each part? How can the SAS codes be able to rank three orders within the same ID?" The order should start with 0, and end till the next 0, so there are three parts (the black, red and blue t) for the same ID. ID Visit CurrentTotal TargetTotal 1 0 0 0 1 0 1 0 1 1 0 1 1 0 3 0 1 1 2 1 1 1 1 2 1 1 0 3 Thank you very much. Looking forward to the solutions.
... View more