Dear members,
I have been trying to figure out the correct syntax for my issue but to no avail.
I have a dataset with multiple firms and team members (identified using BvdIdNumber (firmid) and DMUci (personid)).
I also created some variables called SenMan and Board (dummies) to see based on the string variable TypeRole whether the person is part of the senior management (TMT) or board (BoD) or both (I looked whether they contained the word Board and SenMan).
Additionally, I have created a variable to determine whether the person is unique within the company using tag(BvdIdNumber DMUci).
However, a person can be in the dataset multiple times but one observation may say they are in the board and the next might say they are part of the senior management (both are true).
I used the following code first to try to create three new variables, namely TMTpercompany, BoDpercompany and TMT_BoDpercompany which should check how many members of each are present for a firm.
However (a bit as expected) this would not always generate the correct result since it only indicates a 1 for one of the observations of the individual which might be the one where they are stated as senior management.
But, it then disregards the next observation of that individual which might state they are part of the board (since the dummy = 0)).
I then tried creating a variable using tag( BvdIdNumber DMUci TypeRole) but that also did not give the desired result.
I added an example using dataex below with the original variables and the ones I created + the results of the code after using tag( BvdIdNumber DMUci TypeRole). I used anonymized ID's using the new variables BvdIdNumber2 & DMUci2.
Thanks in advance!
Best regards,
Laura
I have been trying to figure out the correct syntax for my issue but to no avail.
I have a dataset with multiple firms and team members (identified using BvdIdNumber (firmid) and DMUci (personid)).
I also created some variables called SenMan and Board (dummies) to see based on the string variable TypeRole whether the person is part of the senior management (TMT) or board (BoD) or both (I looked whether they contained the word Board and SenMan).
Additionally, I have created a variable to determine whether the person is unique within the company using tag(BvdIdNumber DMUci).
However, a person can be in the dataset multiple times but one observation may say they are in the board and the next might say they are part of the senior management (both are true).
I used the following code first to try to create three new variables, namely TMTpercompany, BoDpercompany and TMT_BoDpercompany which should check how many members of each are present for a firm.
Code:
bysort BvdIdNumber: egen TMTpercompany = total(distinctUCI) if SenMan == 1 bysort BvdIdNumber (TMTpercompany) : replace TMTpercompany= TMTpercompany[_n-1] if missing(TMTpercompany) bysort BvdIdNumber: egen BoDpercompany = total(distinctUCI) if Board== 1 bysort BvdIdNumber (BoDpercompany) : replace BoDpercompany= BoDpercompany[_n-1] if missing(BoDpercompany) bysort BvdIdNumber: egen TMT_BoDpercompany = total(distinctUCI) if SenMan == 1 | Board== 1 bysort BvdIdNumber (TMT_BoDpercompany) : replace TMT_BoDpercompany= TMT_BoDpercompany[_n-1] if missing(TMT_BoDpercompany)
However (a bit as expected) this would not always generate the correct result since it only indicates a 1 for one of the observations of the individual which might be the one where they are stated as senior management.
But, it then disregards the next observation of that individual which might state they are part of the board (since the dummy = 0)).
I then tried creating a variable using tag( BvdIdNumber DMUci TypeRole) but that also did not give the desired result.
I added an example using dataex below with the original variables and the ones I created + the results of the code after using tag( BvdIdNumber DMUci TypeRole). I used anonymized ID's using the new variables BvdIdNumber2 & DMUci2.
Thanks in advance!
Best regards,
Laura
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(BvdIdNumber2 DMUci2) byte(SenMan Board distinctuci distinctBVD_UCI_ROLE) float(TMTpercompany BoDpercompany TMT_BoDpercompany) 15260 943129 1 0 0 0 2 1 3 15260 943129 1 0 0 1 2 1 3 15260 943129 0 1 0 1 2 1 3 15260 943129 1 0 1 0 2 1 3 15260 1007251 1 0 1 1 2 1 3 15261 1459 0 1 1 1 1 2 2 15261 694631 1 1 1 1 1 2 2 15262 476063 1 1 1 1 1 1 1 15263 626434 1 0 1 1 3 . 3 15263 1008172 1 0 1 1 3 . 3 15263 1008543 1 0 1 1 3 . 3 15264 653207 1 0 1 1 2 . 2 15264 596645 1 0 1 1 2 . 2 15265 581619 1 0 1 1 1 . 1 15266 754631 1 0 1 1 5 4 7 15266 365267 1 0 1 1 5 4 7 15266 160481 1 1 0 1 5 4 7 15266 160481 1 1 1 0 5 4 7 15266 249528 0 1 0 1 5 4 7 15266 471543 1 0 1 1 5 4 7 15266 857349 0 1 1 1 5 4 7 15266 249528 1 1 1 1 5 4 7 15266 249528 1 1 0 0 5 4 7 15267 742279 1 1 1 1 5 2 5 15267 657157 1 0 1 1 5 2 5 15267 742279 1 0 0 1 5 2 5 15267 931618 1 0 0 0 5 2 5 15267 742279 1 1 0 1 5 2 5 15267 657157 1 0 0 0 5 2 5 15267 931618 1 0 1 1 5 2 5 15268 682720 1 0 1 1 1 . 1 15269 694630 1 0 1 1 2 1 2 15269 350123 1 1 1 1 2 1 2 15270 502102 1 0 1 1 3 1 3 15270 502102 1 1 0 1 3 1 3 15270 348714 1 0 1 1 3 1 3 15270 502102 1 0 0 0 3 1 3 end

Comment