Hi,
I have variables "Dummy", "ctry1" and "ctry2" and expect to get "DifferentDummy" (table like below).
| Dummy | ctry1 | ctry2 | DifferentDummy |
| 0 | FR | FR | 0 |
| 0 | FR | IE | 0 |
| 1 | FR | FR | 0 |
| 1 | FR | IE | 1 |
I used the following code,
Code:
gen DifferentDummy =0
replace DifferentDummy =1 if (Dummy ==1) & ("`ctry1'"!=="` ctry2'")
| Dummy | ctry1 | ctry2 | DifferentDummy |
| 0 | FR | FR | 0 |
| 0 | FR | IE | 0 |
| 1 | FR | FR | 1 |
| 1 | FR | IE | 1 |
Many thanks in advance.

Comment