I have duplicates that share values, but some are missing. I would like to keep the observation of each duplicate pair that has the least missing values.

I've used egen notmissing = rownonmiss(varlist) to count the number of non-missing variables per observation.

What command can I use to then remove duplicates based on which has the lowest notmissing-count?