When ties are present, pick between the tying variables randomly. Values of 0 are common, but if all of the 16 variables have a value of 0, return a value of 0.
For example, here is a sample of what ten observations might look like, the same example in code, and the desired output:
ID | cat1 | cat2 | cat3 | cat4 | cat5 | cat6 | cat7 | cat8 | cat9 | cat10 | cat11 | cat12 | cat13 | cat14 | cat15 | cat16 |
1001 | 0 | 0 | 0 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1002 | 0 | 0 | 0 | 0 | 0 | 3.5 | 0 | 0 | 0 | 5 | 0 | 0 | 0 | 0 | 0 | 0 |
1003 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1004 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1005 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1006 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1007 | 0 | 0 | 4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 0 | 0 | 0 | 0 |
1008 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1009 | 0 | 3.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3.75 | 8 | 0 | 0 |
1010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int id byte cat1 float cat2 byte(cat3 cat4 cat5) float cat6 byte(cat7 cat8 cat9 cat10 cat11 cat12) float cat13 byte(cat14 cat15 cat16) 1001 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 1002 0 0 0 0 0 3.5 0 0 0 5 0 0 0 0 0 0 1003 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1004 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1005 0 0 2 0 0 0 0 3 0 0 0 0 0 0 0 0 1006 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1007 0 0 4 0 0 0 0 0 0 0 0 4 0 0 0 0 1008 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1009 0 3.75 0 0 0 0 0 0 0 0 0 0 3.75 8 0 0 1010 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 5 end
ID | catSummary |
1001 | 4 |
1002 | 10 |
1003 | 0 |
1004 | 0 |
1005 | 8 |
1006 | 0 |
1007 | 12 |
1008 | 0 |
1009 | 14 |
1010 | 8 |
0 Response to summarizing multiple variables for each observation -- ties broken randomly
Post a Comment