You do not give the second record in the 'pairs' dataset, but I presume it
should be '2 4' -- which as I understand it would imply that the last
element in 'hhid' above should be '2', not '4'. This will achieve that: