[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: How to get the mode within varlist
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?
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: