Dear all,

I have 2 sets of 8 variables and want to do
egen x = anycount(varlist) values(1 3 6 7)
for all of them.

The complication is that the variable are hierarchical, e.g. if there was a match in the 2nd variable of the 1st set, then a potential match in the 2nd variable of the 2nd set should not be counted again. In this case, the command should only count 1 and not 2.

Does anybody have an idea how to implement this?

Thank you very much!