Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: Compute Modus accross variablesCompute Modus accross variables

From   Christian Hunkler <>
Subject   st: Compute Modus accross variablesCompute Modus accross variables
Date   Sat, 04 Dec 2010 16:41:28 +0100

I am looking for a command / ado that allows to compute the mode accross variables, possibly also for strings.

E.g. if  I had these data:

id     var1      var2       var3
1     1991     1992     1991
2     1960     1961     1961
3     1920     1920     1921

I would like to compute a variable storing the mode across lines:
id     mode
1     1991
2     1961
3     1920

I know this can easily done by some simple reshaping using -egen mode by- collapsing and merging the data again, but we deal with pretty large datasets (reshaping takes minutes) and we have to do this for a couple of variables. And we have to do this for variables storing names (which is possible with -egen mode by-).

Maybe there is something available to do this, I haven't found yet?


Christian Hunkler

University of Mannheim, 68131 Mannheim, Germany
 Chair for Sociological Theory,, +49(0)621/181-2024 Phone |-2021 Fax |-2022 Secretary
 MEA - Mannheim Research Institute for the Economics of Aging,, +49(0)621/181-3343 Phone |-1863 Fax

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index