Dear Stata users,

I encounter this question when using one-to-one matching. The variable id is number of observations, the variable chosen stores the observation number of the matched observation. I want to generate an indicator variable (i.e. matched) that equals 1 if id number can be found in corresponding variable chosen, and equals 0 if not. For example, matched in line three will take value 1 because you can find number 3 in variable chosen, line six also takes value 1 because you can find number 6 in variable chosen. I can't find a solution, hope someone could help me. Thank you!

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(id chosen matched)
 1  . 1
 2  . .
 3  . 1
 4  . .
 5  . .
 6  . 1
 7  . 1
 8  . .
 9  . 1
10  . .
11  . 1
12  . .
13  . .
14  . 1
15  . .
16  . .
17  . 1
18  . .
19  1 .
20  3 .
21  6 1
22  7 1
23  9 .
24 11 1
25 14 .
26 17 1
27 21 .
28 22 .
29 24 .
30 26 .
end
label var id "observations ID"
label var chosen "chosen observations (value==id)"
label var matched "indicator that observation was choosed"