I cannot for the life of me figure out how to use a counter or egen or _n to create the variable "Cond_Num_Within_Person," depicted in the third column, below. Help!
I want the counter to (1) reset at each new person and (2) only augment when/if a new condition is seen within that individual. I have manually inputted what I hope for in column three.
I want the counter to (1) reset at each new person and (2) only augment when/if a new condition is seen within that individual. I have manually inputted what I hope for in column three.
| Person_ID | Condition | Cond_Num_Within_Person |
| Abby | T | 1 |
| Abby | T | 1 |
| Abby | T | 1 |
| Abby | C | 2 |
| Ben | T | 1 |
| Ben | T | 1 |
| Ben | T | 1 |
| Carl | T | 1 |
| Carl | C | 2 |
| Carl | C | 2 |
| Carl | C | 2 |

Comment