Dear all,
As you can see, I have 2 variables, namely id and person. I want to create a third variable (i.e. reference_id) that counts how many of the same id occurs for a particular person.
I've used egen reference_id= count (id), by (person), however, this gives me an error because the variable id is a combination of numeric and strings. Can somebody give me feedback, please? I've tried destring as well but it gives me also an error.
This is the result I would like to have:
Thank you in advance!
As you can see, I have 2 variables, namely id and person. I want to create a third variable (i.e. reference_id) that counts how many of the same id occurs for a particular person.
I've used egen reference_id= count (id), by (person), however, this gives me an error because the variable id is a combination of numeric and strings. Can somebody give me feedback, please? I've tried destring as well but it gives me also an error.
This is the result I would like to have:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str3 ID str1 Person byte reference_id "O78" "A" 2 "P34" "A" 1 "M98" "A" 1 "O78" "A" 2 end
Comment