Dear all,

I have a variable of unique ids for a dataset of survey respondents which I have matched based on location to aid projects which are nearby. Therefore for each unique id respondent I have generated a number of matches corresponding to the aid projects that are located nearby. I have another variable donor which tells me who was the donor (China or World Bank) for each aid project and dummy variables for whether the donor's aid project was active at the time that the respondent was surveyed.

PHP Code:

id  aidproj_id   km_to_aidproj_id
1    P345    1.8943017
1    P341    1.8943017
1    P347    1.8943017
1    P342    1.8943017
1    P332    5.2169379
1    P357    14.888029
1    P346    1.8943017
1    P356    3.6336806
1    P330    8.0394558
1    P331    5.2169379 


I wish to create a dummy for each unique id (which now essentially act as group identifiers for matched observations) which tells me whether both aid projects were active at the time of surveying or only one of the two. I think I'm missing a basic step here but I can't quite figure out what command will give me what I need.

I would like:

for each id create a dummy where
1== when for at least one of the matched observations both China and the World Bank were active.
0==when for all the matched observations only one donor was active.

I am somewhat of novice stata user so apologies if the command required is rather basic although I can't seem to find a solution anywhere.