Hi,
I am new to Stata.
I am trying to generate a new variable that counts the occurrence of each level of my categorical variable (4 levels), by id. Each id occurs 15 times (15 rows per id). So far I have found the following solution:
This does give me an answer but it is formatted as a list. I would like the result to be printed in a new variable/ vector so that I can use it in subsequent analyses. I understand that there will only be one row with a value for each individual for this new variable.
Thanks for your help!
I am new to Stata.
I am trying to generate a new variable that counts the occurrence of each level of my categorical variable (4 levels), by id. Each id occurs 15 times (15 rows per id). So far I have found the following solution:
Code:
by id: count if Variable_cat==`"A"'
Thanks for your help!
Comment