I have a monadic dataset of alliances where I am trying to predict secret alliances and I claim that prior experience with alliances, prior secret alliances, and having previously made an alliance with another state in the alliance in the past increases the probability of a state making a secret alliance in the future.
I have already coded the previous alliance and previous secret alliance variables with temporal constraints of 20, 25, and 30 years. So there are three different variables here. What I need is a variable indicating whether the state in question has made a previous alliance with one of the other states in an alliance within the past 10, 15, 20, 25, or 30 years (so five different variables).
I think it is a pretty straightforward thing to do and should go pretty quickly (but it is above my coding abilities). The most difficult thing about it is that the alliance dataset would be dyadic (pairs of alliances), whereas the alliance I am working off of is monadic (one observation for each member of each alliance). However, the dataset has unique identifiers for each alliance, so that should merge easily. So the data would ideally need to be coded in the dyadic dataset and then the info from that merged with the state and alliance number in the monadic datset I have built.
So, if the US has an alliance with Canada in 1972, the questions I need answered are if the US signed an alliance with Canada in the past 10, 15, 20, 25, or 30 years. In the dyadic dataset, there is an entry for the US-Can alliance in 1972.
Ideally, I'd like to see this done in Stata and get the code.
Also, one other thing that would take a few minutes is I would like to know the temporal distance between different secret alliances to see if time is a factor. So, if the US signed a secret alliance on 11/3/1908 and another one on 5/4/1928, what is the time difference between these two dates? While I know how to do this if it is within the same observation, I don't know how to do this if it is in different observations (some kind of a loop or egen command, perhaps).
I need a couple of variables coded in one dataset and then merged into another.
I don't think it would take more than twenty minutes for someone who knows the code. It would actually probably take less time than that.
Preferably, I'd like to have it by Friday.
Basically, I know how to build the variables I need across the same observation, but not when it comes to different observations.