Dear Statalists,
for my research on repeated alliances I am using a dataset in which each observation represents one alliance. I want to group observations such that alliances between the same participating companies appear in one group. For this I have two string variables, part_cusip1 and part_cusip2, which each contain the CUSIP Number of Partner 1 and Partner 2 respectively. Unfortunately, there are observations in which the same participants are present, but the relative positions of the CUSIP Numbers is exchanged. When I use egen idgroup=group(part_cusip1 part_cusip2), it ignores those observations and considers them a group in and of itself. Consider following example of how the data looked after I used the command:
obs idgroup part_cusip1 part_cusip2
1 1 000001 000002
2 1 000001 000002
3 2 000002 000001
4 1 000001 000002
5 3 000003 000004
As you can see, while the same participants are involved in observation 3 (000001 & 000002), the command considers it as its own group. Is there any way to circumvent this problem? My dataset has 36000 observations, so checking if each part_cusip1 appears in part_cusip2 and then manually changing idgroup if the same participants are involved would be a lot of work and I would prefer to avoid it.
Thank you for your help!
Related Posts with Forming groups by two string variables that are interchangeable
Regression output - Bug?Hi everyone, I am trying to run some old code (version 14.2) using a new Stata version (15.1) on a …
forval returning error stating ambiguous abbreviation for variables b_01 and b_11I have a set of variables labelled b_01, b_02, b_03.....b_11, b_12, ....b_20 and similarly another s…
Outreg2 providing one-sided p-valuesDear Stata users, I have a question regarding the one-sided p-value in outreg2, which I use to expo…
Create a dummy variable that equals 1 if the compensation committee is comprised wholly of independent directorsHi everyone, I am new to the stata forum and I have some questions. To run my regression, I need som…
split, parse(,) maximum number of variables reachedDear all, I'm using Stata 15 and trying to split a string variable into different component which ar…
Subscribe to:
Post Comments (Atom)
0 Response to Forming groups by two string variables that are interchangeable
Post a Comment