{smcl} {* 13 May 2003/17 November 2009}{...} {cmd:help modes}{right:({browse "http://www.stata-journal.com/article.html?article=up0026":SJ9-4: sg113_2})} {hline} {title:Title} {p 4 4 2}{hi:modes} {hline 2} Tabulation of mode(s) {title:Syntax} {p 8 17 2} {cmd:modes} {varname} {ifin} {weight} [{cmd:,} {c -(} {cmdab:m:in(}{it:#}{cmd:)} {c |} {cmdab:n:modes(}{it:#}{cmd:)} {c )-}{break} {opth gen:erate(newvar)}] {pstd} {cmd:fweight}s and {cmd:aweight}s are allowed; see {help weight}. {title:Description} {p 4 4 2} {cmd:modes} tabulates the mode(s) of {it:varname}, that is, the value(s) of {it:varname} that occur most frequently. {it:varname} may be numeric or string. Missing values are ignored. {p 4 4 2} {cmd:modes} is most obviously useful with a discrete or categorical variable. Continuous variables may need to be placed in bins or classes first. {title:Options} {p 4 8 2}{cmd:min(}{it:#}{cmd:)} specifies that all values with a frequency of {it:#} or more should be shown. {p 4 8 2}{cmd:nmodes(}{it:#}{cmd:)} specifies that {it:#} modes should be shown. However, if ties in frequency make identification of precisely {it:#} modes arbitrary, all such tied modes will be shown. Note that fewer modes will be shown if fewer than {it:#} modes exist. {p 8 8 2}{cmd:min()} and {cmd:nmodes()} may not be specified together. {p 4 8 2}{cmd:generate(}{it:newvar}{cmd:)} generates an indicator variable that is missing if {it:varname} is missing or observations are excluded by {cmd:if} or {cmd:in}, is 1 whenever the value of {it:varname} is one of the displayed modes, and is 0 otherwise. {title:Examples} {p 4 8 2}{cmd:. modes rep78}{p_end} {p 4 8 2}{cmd:. modes rep78 if foreign}{p_end} {p 4 8 2}{cmd:. modes mpg, min(3)}{p_end} {p 4 8 2}{cmd:. modes mpg, nmodes(3)}{p_end} {p 4 8 2}{cmd:. modes turn, nmodes(10) generate(flag)} {title:Author} {p 4 4 2}Nicholas J. Cox, Durham University, UK{break} n.j.cox@durham.ac.uk {title:Acknowledgments} {p 4 4 2}A problem posed by Sylvain Friederich led to the {cmd:nmodes()} option. A problem posed by Elan Cohen led to the {cmd:generate()} option. {title:Also see} {psee} Article: {it:Stata Journal}, volume 9, number 4: {browse "http://www.stata-journal.com/article.html?article=up0026":sg113_2},{break} {it:Stata Journal}, volume 3, number 2: {browse "http://www.stata-journal.com/article.html?article=up0003":sg113_1},{break} {it:Stata Technical Bulletin} 50: {browse "http://www.stata.com/products/stb/journals/stb50.html":sg113} {psee}Online: {manhelp tabulate R}, {manhelp kdensity R}, {manhelp egen D} {p_end}