Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: Row mode |

Date |
Thu, 16 May 2013 08:31:17 +0100 |

See http://www.stata.com/statalist/archive/2013-04/msg00301.html for a comment on expressions like "a data". The easiest way I know is to -reshape- before and after. Note that -egen, mode()- won't play with your 4th example, where 3 and 4 tie for mode, so you need a rule such as -minmode-. . l +---------------------------+ | row1 row2 row3 row4 | |---------------------------| 1. | 1 3 1 4 | 2. | 3 3 4 1 | 3. | 1 4 2 2 | 4. | 4 4 3 3 | +---------------------------+ . gen id = _n . reshape long row, i(id) (note: j = 1 2 3 4) Data wide -> long ----------------------------------------------------------------------------- Number of obs. 4 -> 16 Number of variables 5 -> 3 j variable (4 values) -> _j xij variables: row1 row2 ... row4 -> row ----------------------------------------------------------------------------- . egen mode = mode(row), by(id) minmode . reshape wide (note: j = 1 2 3 4) Data long -> wide ----------------------------------------------------------------------------- Number of obs. 16 -> 4 Number of variables 4 -> 6 j variable (4 values) _j -> (dropped) xij variables: row -> row1 row2 ... row4 ---------------------------------------------------------------------- Nick njcoxstata@gmail.com On 16 May 2013 07:20, Md. Alauddin Majumder <mm4v@mtmail.mtsu.edu> wrote: > Dear Statalist, > I have a data like the following: > > Row1 Row2 Row3 Row4 > 1 3 1 4 > 3 3 4 1 > 1 4 2 2 > 4 4 3 3 > > I want to find ROW MODE. Any help will be greatly appreciated! > > Thanks in advance > Majumder > > > > > > > > > > > > > > > > > > > > > > > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: st: Row mode***From:*"Md. Alauddin Majumder" <mm4v@mtmail.mtsu.edu>

**References**:**st: Row mode***From:*"Md. Alauddin Majumder" <mm4v@mtmail.mtsu.edu>

- Prev by Date:
**Re: st: Row mode** - Next by Date:
**Re: st: Fixed effects in nonlinear least squares** - Previous by thread:
**Re: st: Row mode** - Next by thread:
**RE: st: Row mode** - Index(es):