Hello,
I hope this is not a redundant question (I'm rather new to Stata) but I haven't yet found an attractive solution to my problem.
I need to identify (and later drop) observations that have a value in one variable (ID_1) which is equal to another observation's value of a different variable (ID_2) under the condition that both observations have the same date and the matched observation has a specific value in an indicator variable (either C or W). I would like to generate a dummy variable that ticks the corresponding observations first before I drop them.
Here, the simplified data:
For example, I would like to the dummy variable to mark the first observation with ID_1=28896 because the third line item's ID_2 matches that ID_1 while it has the same date and also the Indicator equals "W" instead of "T". The same applies to the fifth observation which should be marked due to the last line item.
I am sorry, I cannot provide a code, I have tried different approaches using forvalue and duplicates but nothing worked properly.
Thanks and best regards,
Fred
I hope this is not a redundant question (I'm rather new to Stata) but I haven't yet found an attractive solution to my problem.
I need to identify (and later drop) observations that have a value in one variable (ID_1) which is equal to another observation's value of a different variable (ID_2) under the condition that both observations have the same date and the matched observation has a specific value in an indicator variable (either C or W). I would like to generate a dummy variable that ticks the corresponding observations first before I drop them.
Here, the simplified data:
Firm | ID_1 | ID_2 | Date | Indicator |
1 | 28896 | 07. Feb 03 | T | |
2 | 29105 | 07. Feb 03 | T | |
1 | 29106 | 28896 | 07. Feb 03 | W |
3 | 29126 | 07. Feb 03 | T | |
3 | 29254 | 07. Feb 03 | N | |
4 | 29283 | 07. Feb 03 | T | |
3 | 29288 | 29254 | 07. Feb 03 | C |
For example, I would like to the dummy variable to mark the first observation with ID_1=28896 because the third line item's ID_2 matches that ID_1 while it has the same date and also the Indicator equals "W" instead of "T". The same applies to the fifth observation which should be marked due to the last line item.
I am sorry, I cannot provide a code, I have tried different approaches using forvalue and duplicates but nothing worked properly.
Thanks and best regards,
Fred
Comment