I have a dataset that looks like below. For each of the IDs, there are multiple locations. What I want to do is to replace the location for ids with one mode to the value of the mode. For the ids that have multiple modes of locations, I'll keep the location as it is. In addition, I want to know how many unique ids have multiple modes for location.
I wonder if anyone know how to realize that in stata? I was using the command
Code:
bysort id (location):egen mode = mode(location)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float id str1 location 1 "A" 1 "A" 1 "A" 1 "B" 2 "C" 2 "C" 2 "C" 2 "D" 2 "D" 2 "D" 3 "E" 3 "E" 3 "E" 3 "F" 3 "F" 3 "F" end
0 Response to Multiple modes
Post a Comment