Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems keeping only certain values of a variable and removing the other values

    Hi all,

    I have a panel dataset with board data for U.S. firms.
    One of the variables is "RoleName" which consist of officers, directors, chairmans etc.
    However, I would like to only keep keep CEO, Chairman/President/CEO or President/CEO. for the variable "RoleName".
    I tried to solve the problem with the following codes but it didn't work:

    Code 1

    keep if RoleName == "CEO" "Chairman/President/CEO" "President/CEO"
    Code 2

    egen ROLE = anymatch (RoleName), values ("CEO" "President/CEO" "Chairman/President/CEO")

    Code 2, didn't work according to Stata because RoleName is a string variable but after using the code: list RoleName if missing(real(RoleName)) it didn't change into a numeric variable.

    Which code should I use to only keep the values CEO, Chairman/President/CEO or President/CEO and remove the other observations that "RoleName" (e.g. Independent Director) has?
    I'm using Stata 17 on a macOs Catalina version 10.15.7.

    Below a sample of my dataset:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str12 ISIN str192 BoardName str150 RoleName str384 DirectorName double(TimeRole TotalCompensation NumberDirectors)
    "BMG169621056" "BUNGE LTD"                                    "CEO"                                 "Greg Heckman"               .7    . 11
    "BMG169621056" "BUNGE LTD"                                    "CEO"                                 "Greg Heckman"              1.7    . 10
    "BMG169621056" "BUNGE LTD"                                    "CEO"                                 "Soren Schroder"            3.5    . 11
    "BMG169621056" "BUNGE LTD"                                    "CEO"                                 "Soren Schroder"            4.5    . 10
    "BMG169621056" "BUNGE LTD"                                    "CEO"                                 "Soren Schroder"            5.5    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Andreas Fibig"              .3    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Andreas Fibig"             1.3    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Andrew Ferrier"              4    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Andrew Ferrier"              5    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Andrew Ferrier"              6    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Andrew Ferrier"              7    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Bernardo Hees"               0    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Bernardo Hees"               1    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Carol Browner"             3.3    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Carol Browner"             4.3    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Carol Browner"             5.3    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Carol Browner"             6.3    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Carol Browner"             7.3    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Count Paul de Ways Ruart"  1.4    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Count Paul de Ways Ruart"  2.4    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Count Paul de Ways Ruart"  3.4    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Enrique Boilini"          15.6    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Enrique Boilini"          16.6    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Enrique Boilini"          17.6    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Ernest Bachrach"          15.9    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Ernest Bachrach"          16.9    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Ernest Bachrach"          17.9    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Greg Heckman"               .2    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Jay Winship IV"             .2    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Jay Winship IV"            1.2    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Jay Winship IV"            2.2    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "John McGlade"              2.3    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "John McGlade"              3.3    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "John McGlade"              4.3    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Jon Fyrwald"                 0    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Jon Fyrwald"                 1    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Jon Fyrwald"                 2    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Chairman"                "Kathi Hyle"                  0    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Chairman"                "Kathi Hyle"                  1    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Chairman"                "Kathi Hyle"                  2    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Kathi Hyle"                4.4    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Kathi Hyle"                5.4    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Chairman"                "Lawrence Lupo"             2.9    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Chairman"                "Lawrence Lupo"             3.9    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Lawrence Lupo"             4.1    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Mark Zenuk"                 .4    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Mark Zenuk"                1.4    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Mark Zenuk"                2.4    . 10
    "BMG169621056" "BUNGE LTD"                                    "Director - SD"                       "Paul Fribourg"              .2    . 15
    "BMG169621056" "BUNGE LTD"                                    "Director - SD"                       "Paul Fribourg"             1.2    . 11
    "BMG169621056" "BUNGE LTD"                                    "Director - SD"                       "Paul Fribourg"             2.2    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "The Hon. Sheila Bair"        0    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "The Hon. Sheila Bair"        1    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Vinita Bali"                .9    . 15
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Vinita Bali"               1.9    . 11
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "Vinita Bali"               2.9    . 10
    "BMG169621056" "BUNGE LTD"                                    "Independent Director"                "William Engels"           15.9    . 11
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "CEO"                                 "Matthijs Glastra"           .3    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "CEO"                                 "Matthijs Glastra"          1.3    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "CEO"                                 "Matthijs Glastra"          2.3    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "CEO"                                 "Matthijs Glastra"          3.3    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "CEO"                                 "Matthijs Glastra"          4.3    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Brian King"                 .6    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Brian King"                1.6    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Brian King"                2.6    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Brian King"                3.6    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Dennis Fortino"            5.8    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Dennis Fortino"            6.8    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "DiSanzo Eldracher"          .6    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "DiSanzo Eldracher"         1.6    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Dom Romeo"                 4.5    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Dom Romeo"                 5.5    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Dom Romeo"                 6.5    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Dom Romeo"                 7.5    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Harry Bosco"               4.5    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Ira Lamel"                 5.8    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Ira Lamel"                 6.8    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Ira Lamel"                 7.8    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Ira Lamel"                 8.8    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Ira Lamel"                 9.8    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Director - SD"                       "Lonny Carpenter"            .6    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Lonny Carpenter"            .9    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Lonny Carpenter"           1.9    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Maxine Mauricio"            .6    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Chairman"                "Stephen Bershad"           5.8    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Chairman"                "Stephen Bershad"           6.8    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Chairman"                "Stephen Bershad"           7.8    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Chairman"                "Stephen Bershad"           8.8    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Chairman"                "Stephen Bershad"           9.8    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Thomas Secor"              4.5    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Thomas Secor"              5.5    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Thomas Secor"              6.5    .  7
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Thomas Secor"              7.5    .  8
    "CA67000B1040" "NOVANTA INC (GSI Group Inc prior to 05/2016)" "Independent Director"                "Thomas Secor"              8.5    .  8
    "NL0009434992" "LYONDELLBASELL INDUSTRIES NV"                 "Chairman (Independent Board Member)" "Bob Gwin"                  3.3  215 17
    "NL0009434992" "LYONDELLBASELL INDUSTRIES NV"                 "CEO"                                 "Bob Patel"                  .5 1574 12
    "NL0009434992" "LYONDELLBASELL INDUSTRIES NV"                 "CEO"                                 "Bob Patel"                 1.5 1575 12
    "NL0009434992" "LYONDELLBASELL INDUSTRIES NV"                 "CEO"                                 "Bob Patel"                 2.5 1636 11
    "NL0009434992" "LYONDELLBASELL INDUSTRIES NV"                 "Chairman/CEO"                        "Bob Patel"                 1.9 1342 17
    "NL0009434992" "LYONDELLBASELL INDUSTRIES NV"                 "Chairman/CEO"                        "Bob Patel"                 2.9 1498 16
    end
    Thanks in advance!


  • #2
    Not sure if I fully understand your concern. But if your question is "keep the values CEO, Chairman/President/CEO or President/CEO and remove the other observations that "RoleName" (e.g. Independent Director) has?", I would try

    Code:
    . keep if RoleName == "CEO" | RoleName == "Chairman/President/CEO" | RoleName == "
    > President/CEO"

    Comment


    • #3
      I don't know how to do it with the double quotation marks in the value.

      But I tried to remove the quotation marks first: the first line below was inspired by Dr. Cox.

      replace RoleName = subinstr(rolename,`"""', "", .)

      keep if RoleName == "CEO" | Rolename == "President/CEO"
      Last edited by Anqi Zhang; 12 May 2022, 13:45.

      Comment


      • #4
        Thank you very much, it worked!!

        Comment

        Working...
        X