Finding All Modal Values for Subgroups of Cases
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | * Question: I have a list of id and amounts. I would like to find the mode(s) by id. * Answer: Raynald Levesque 2005/11/29 www.spsstools.net . DATA LIST LIST /id amt. BEGIN DATA 1 10 1 10 1 15 1 15 1 25 2 25 2 30 3 40 4 15 4 25 4 25 4 50 4 50 4 50 4 25 4 75 END DATA. * Find multi-modal values per id. AGGREGATE OUTFILE=* /BREAK=id amt /nbOfTimes=N. EXECUTE. AGGREGATE /BREAK=id /maxNbOfTimes=MAX(nbOfTimes). SELECT IF maxNbOfTimes = nbOfTimes. EXECUTE. |
Related pages
...