Dear Statalist- Community,

I would like to create a dummy called "multiple" indicating whether there are duplicates in the value of the variables "_`i'LSLA_id" (with `i' == 1/`r(max)').

For instance:

If "_1LSLA_id" == 110 and "_4LSLA_id" == 110, my dummy "multiple" should be equal to one.


So far:

My code below only tests whether variables with the variable names "i" and "i - 1" have the same values. However, I would like to detect all duplicated values testing for j != i.


Code:
gen multiple =0
sum numberwithin200
forvalues i = 2/`r(max)'{
local j = `i' -1
replace multiple = 1 if _`i'LSLA_id == _`j'LSLA_id
}
Does anyone have an idea on how to modify the command? Thank you very much for your help in advance!

Warm regards,
Bianca