Hi Statalist,

Apologies for the vagueness of the question. Hopefully the details would make it clearer. Please consider the following example data

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(id round) byte female
1 1 1
1 2 0
1 3 1
1 4 1
1 5 1
2 1 0
2 2 0
2 4 0
2 5 0
3 1 1
3 2 0
3 3 0
3 5 .
4 1 .
4 2 .
4 5 .
end


female is a binary variable denoting sex of individual. Now as you can see, there is some discrepancy in its value across rounds. This discrepancy exists in the raw data, which can be attributed to recording errors at the time of enumeration. To correct this, I'm operating on the premise that the enumerator is unlikely to make identical mistakes in multiple rounds. So, for a given individual, the value of female that appears the least number of times must be the erroneous value and needs to be corrected. This is why I want to replace the value of female (or generate a variable say female1), which for each individual, takes the value appearing maximum number of times, across all available rounds. So, I would like my data to look like this:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(id round) byte female float female1
1 1 1 1
1 2 0 1
1 3 1 1
1 4 1 1
1 5 1 1
2 1 0 0
2 2 0 0
2 4 0 0
2 5 0 0
3 1 1 0
3 2 0 0
3 3 0 0
3 5 . 0
4 1 . .
4 2 . .
4 5 . .
end
If there are some missing values, the non missing values are to be considered. If values are missing for all rounds, then resultant value would be missing.

Would appreciate any help on this!
Thanks