Hi all,

I am trying to identify cases that are duplicates on two variables "agencyname" and "statefips" but have distinct values on a third variable "agencyid".

I used the code
Code:
duplicates tag agencyname statefips, gen(agencydup)
to identify the cases that have the same string agency name and the same numeric state fips code, but I cannot figure out how to modify the code to only identify cases within those duplicate agencyname-statefips groups that differ on my numeric agency id variable. Could anyone please help me with this?

On an unrelated note, for identifying duplicate cases, could someone please explain to me the difference between the following 3 lines of code. I was told to use the last one for identifying duplicates but do not know what they are doing differently.

Code:
egen dup= tag(agencyname statefips)
Code:
duplicates tag agencyname statefips, gen(dup)
Code:
bys agencyname statefips: gen dup = cond(_N == 1, 0, _n)
Thank you so much for any help.
Tom