Announcement

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

  • Summinig a variable for a particular year

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int year str15 boardmember str17 firm long totalassets
    2009 "Caiaphas Leo"    "1spatial PLC"         2524
    2010 "Sunders, David"  "1spatial PLC"       226874
    2011 "Sunders, David"  "1spatial PLC"      1703900
    2012 "Sunders, David"  "1spatial PLC"      3180926
    2013 "Tax Alex"        "1spatial PLC"      4657952
    2014 "Tax Alex"        "1spatial PLC"      6134978
    2015 "Tax Alex"        "1spatial PLC"      7612004
    2016 "Tax Alex"        "1spatial PLC"        15995
    2009 "Froom, Joe"      "3 Holdings"          13087
    2010 "Froom, Joe"      "3 Holdings"        1599732
    2011 "Froom, Joe"      "3 Holdings"          54635
    2012 "Froom, Joe"      "3 Holdings"         151894
    2013 "Tax Alex"        "3 Holdings"         249153
    2014 "Tax Alex"        "3 Holdings"          45929
    2015 "Tax Alex"        "3 Holdings"         201745
    2016 "Tax Alex"        "3 Holdings"         201745
    2009 "Caiaphas Leo"    "4com PLC"           186153
    2010 "Doddy, Jonathan" "4com PLC"           170561
    2011 "Doddy, Jonathan" "4com PLC"           154969
    2012 "Doddy, Jonathan" "4com PLC"           139377
    2013 "Anderson, Craig" "4com PLC"            18365
    2014 "Taylor, Ian"     "4com PLC"           358715
    2015 "Bussey, William" "4com PLC"            11232
    2016 "Bussey, William" "4com PLC"              252
    2017 "Bussey, William" "4com PLC"            53921
    2009 "Caiaphas Leo"    "4D Pharma PLC"      107590
    2010 "Doddy, Jonathan" "4D Pharma PLC"      161259
    2011 "Doddy, Jonathan" "4D Pharma PLC"      214928
    2012 "Doddy, Jonathan" "4D Pharma PLC"      268597
    2013 "Anderson, Craig" "4D Pharma PLC"      322266
    2014 "Pong, Graham"    "4D Pharma PLC"      375935
    2015 "Pong, Graham"    "4D Pharma PLC"      429604
    2016 "Pong, Graham"    "4D Pharma PLC"      483273
    2009 "Lenton, Kevin"   "Baco Capital PLC"   536942
    2010 "Lenton, Kevin"   "Baco Capital PLC"    10270
    2011 "Tax Alex"        "Baco Capital PLC"     3442
    2012 "Tax Alex"        "Baco Capital PLC"    32612
    2013 "Tax Alex"        "Baco Capital PLC"     9146
    2014 "Sun Paul"        "Baco Capital PLC"    16112
    2015 "Sun Paul"        "Baco Capital PLC"   235421
    2016 "Sun Paul"        "Baco Capital PLC"   308944
    2009 "Lenton, Kevin"   "Barclays PLC"       382467
    2010 "Lenton, Kevin"   "Barclays PLC"       455990
    2011 "Sunders, David"  "Barclays PLC"       529513
    2012 "Sunders, David"  "Barclays PLC"       603036
    2013 "Sunders, David"  "Barclays PLC"       676559
    2014 "Sunders, David"  "Barclays PLC"       750082
    2015 "Pong, Graham"    "Barclays PLC"       823605
    2016 "Pong, Graham"    "Barclays PLC"       897128
    2009 "Pong, Graham"    "Coca Cola"          199924
    2010 "Pong, Graham"    "Coca Cola"           31356
    2011 "Pong, Graham"    "Coca Cola"         1572178
    2012 "Taylor Scott"    "Coca Cola"           97391
    2013 "Taylor Scott"    "Coca Cola"           59951
    2014 "Taylor Scott"    "Coca Cola"           68475
    2015 "Kyiu David"      "Coca Cola"             525
    2016 "Kyiu David"      "Coca Cola"           50781
    2017 "Kyiu David"      "Coca Cola"           41383
    2009 "Pong, Graham"    "Genesis Group PLC" 1438242
    2010 "Pong, Graham"    "Genesis Group PLC"   12473
    2011 "Pong, Graham"    "Genesis Group PLC"   29229
    2012 "Taylor Scott"    "Genesis Group PLC"   56596
    2013 "Taylor Scott"    "Genesis Group PLC"   24092
    2014 "Taylor Scott"    "Genesis Group PLC"  315195
    2015 "Kyiu David"      "Genesis Group PLC"  246646
    2016 "Kyiu David"      "Genesis Group PLC"   53258
    2009 "Sun Paul"        "MTN "                  418
    2010 "Sun Paul"        "MTN "                33240
    2011 "Doddy, Jonathan" "MTN "                66062
    2012 "Doddy, Jonathan" "MTN "                98884
    2013 "Sun Paul"        "MTN "               131706
    2014 "Kyiu David"      "MTN "               164528
    2015 "Kyiu David"      "MTN "               197350
    2016 "Kyiu David"      "MTN "               230172
    2009 "Lenton, Kevin"   "Post GPS PLC"      2045689
    2010 "Lenton, Kevin"   "Post GPS PLC"       214517
    2011 "Lenton, Kevin"   "Post GPS PLC"       171362
    2012 "Doddy, Jonathan" "Post GPS PLC"         4890
    2013 "Sun Paul"        "Post GPS PLC"        39218
    2014 "Sun Paul"        "Post GPS PLC"        44855
    2015 "Sun Paul"        "Post GPS PLC"        41010
    2016 "Froom, Joe"      "Post GPS PLC"        14525
    2009 "Lenton, Kevin"   "PP PLC"             267633
    2010 "Lenton, Kevin"   "PP PLC"             214838
    2011 "Lenton, Kevin"   "PP PLC"            2940700
    2012 "Senior, James"   "PP PLC"              50782
    2013 "Senior, James"   "PP PLC"             184099
    2014 "Senior, James"   "PP PLC"               5163
    2015 "Caiaphas Leo"    "PP PLC"              32778
    2016 "Caiaphas Leo"    "PP PLC"               6859
    2017 "Caiaphas Leo"    "PP PLC"             174783
    2009 "Caiaphas Leo"    "Royal Bank"           2084
    2010 "Caiaphas Leo"    "Royal Bank"            448
    2011 "Caiaphas Leo"    "Royal Bank"          13314
    2012 "Caiaphas Leo"    "Royal Bank"           9763
    2013 "Tomsun David"    "Royal Bank"         254743
    2014 "Kyiu David"      "Royal Bank"        1876800
    2015 "Kyiu David"      "Royal Bank"          16861
    2016 "Kyiu David"      "Royal Bank"          42784
    2009 "Caiaphas Leo"    ""                    68707
    end


    Hi for my data above, i seek to do two things;

    Firstly, I want the sum the total assets for a board member for all the firms he/she works for a particular year ie if you take Leo, the sum of all companies he is board member for the year 2009. Same for 2010. such that the new variable will have the same value for all firms in which Leo is a board member for 2009.

    Secondly, i want to divide the total assets of a firm by the earlier variable obtained (ie total assets all firms for which a board member works).

    I am looking to obtain what I call client importance for each board member.

    Thanks a million.

  • #2
    Firstly, I want the sum the total assets for a board member for all the firms he/she works for a particular year ie if you take Leo, the sum of all companies he is board member for the year 2009. Same for 2010. such that the new variable will have the same value for all firms in which Leo is a board member for 2009.
    Code:
    by boardmember year, sort: egen firstly = total(totalassets)
    Secondly, i want to divide the total assets of a firm by the earlier variable obtained
    I am not sure I know what you mean by "total assets of a firm." In the code below, I assume you mean the sum of the values of totalassets among all observations for that firm, separately in each year. If I have misunderstood, modify this code accordingly:
    Code:
    by firm year, sort: egen firm_total_assets = total(totalassets)
    gen secondly = firm_total_assets/firstly
    Do read -help egen-: it contains information about many helpful functions that aggregate observations in groups.

    Comment


    • #3
      Thank you Clyde. It worked. Will also read about the egen. thanks a million.

      Comment

      Working...
      X