Bookmark and Share

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


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

st: RE: Compute Modus accross variablesCompute Modus accross variables


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: Compute Modus accross variablesCompute Modus accross variables
Date   Mon, 6 Dec 2010 11:15:14 +0000

I don't know of code for another way to do it. 

I think the best way to do it without a -reshape- would be to write a Mata function. You'd need to handle ties in frequency with some recipe. 

Nick 
[email protected] 

Christian Hunkler

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?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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