Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: How to get the mode within varlist


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: How to get the mode within varlist
Date   Mon, 7 Feb 2005 17:23:15 -0000

One way to do this is to -reshape-, 
apply -egen, mode()- and then -reshape-
back. 

Nick 
n.j.cox@durham.ac.uk 

Oberschachtsiek Dirk
 
> I am working on a dataset that provides several variables on 
> some attributes (e.g. date of birth). Moreover, this dataset 
> may provide more than one observation per person, too. Thus 
> the dataset holds multiple information for each attribute. 
> However, these attributes are not constant within varlist 
> and/or by observations - and there is no evidence which is 
> the best information to use. 
> 
> A way out of this is to use the -mode- of varlist by 
> observation as the "true" value. Is it possible to solve this 
> by using - egen- [like -bysort id: egen sex = rmode(varlist)- 
> which is not implemented in stata] or is there any other way 
> to get out of this in stata? 
> 
> Example 
> 
> Nr.	Id	var1	var2	var3	outcome_var
> 
> obs1	A	2	1	1	2
> obs2	A	2	2	2	2
> obs3	B	2	2	2	2
> obs4	C	1	1	2	1
> obs5	D	1	1	2	1
> obs6	D	2	1	1	1
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index