I am trying to define a treatment group based on the following relationship. What's going on in the diagram? This diagram illustrates the relationship between two Managers. The analysis is at the Group level and there are only two managers within one group. The big black colored cirlce contains all the firms controlled by that specific manager. The smaller circles in the big circle are divided based on their industry codes. Within these small circles, all the firms that belong to that industry are included. The relationships illustrate whether the firms should be compared or not. What am I trying to do? I am comparing the small circles of one Manager to the same circles that the other Manager may or may not control. Whenever there are comparable industries, then start go to Step 3. If not, then ignore that industry and assign treated=0 for all rows with that particular industry number and group number (all analysis is at the group level). Check whether the two managers are controlling the same firm, if yes then assign treated =1. If all firms are different (distinct) in that specific industry (i.e., no firm is controlled by both managers), then still assign treated = 1. So for Step 3 and 4, it is basically, whenever both managers control firms in the same industry, then assign 1 as treated for all. What did I do in the code? Partition all firms in both A and T (I define A as one manager and T as the other, where A means acquiring manager and T means Targeted manager), in A only, and in B only. For those in both A and T, treated=1 for all firms in this subgroup. For firms in A ONLY, merge its industry with ALL industries that T covers. If merged, treated=1. Symmetrically, for firms in T ONLY, merge its industry with ALL industries that A covers, if merged, treated=1. All other firms get treated=0. Below is what I have done so far as well as my sample. This is an extension to a previous problem that @Shmuel and @gamotte have provided extensive help with. I am posting this as a new question since defining the control and treatment group is often used by researchers as well as practitioners and alternative codes may help others as well. I was able to write a code that gets the result, but I would like to know whether there are alternative and more efficient way to get the result.
... View more