I am trying to find the most common string values across variables. While I work in criminal justice data, I can't share that data. So I made a test set with color. Assume that each respondent might have multiple colors occur. Each time a color occurs, they get the color in a new variable. (In real life, these are charges.) There is no rhyme or reason why something is entered as the first color or second. I need to know the five most common colors that occur across the data set (the five most common charges). I know how to do this for one variable with the group command, but can't figure out how to do so across variables.
I searched the forums, but did not find a solution.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str2 id str6 Color1 str5(Color2 Color3) str6 Color4 "1" "Blue" "" "" "" "2" "Red" "Black" "White" "" "3" "Orange" "Blue" "" "" "4" "Black" "Red" "Blue" "Orange" "5" "Blue" "" "" "" "6" "Blue" "Green" "Tan" "" "7" "Green" "Blue" "" "" "8" "Red" "Blue" "Green" "" "9" "Purple" "" "" "" "10" "Black" "Red" "" "" end
Thank you!
0 Response to Finding Most Common String Values Across Variables
Post a Comment