Announcement

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

  • #16
    Hi

    I just tried this command and it worked....Can you please verify if I did it right?

    . egen new_pane= group(Country company )

    . sort new_pane Years

    . xtset new_pane Years
    panel variable: new_pane (strongly balanced)
    time variable: Years, 2015 to 2017
    delta: 1 unit
    It worked with the same data. I just replaced SIDcodes with company names.

    Comment


    • #17
      Hi Farah,

      As others have mentioned, it would be *really* helpful if you could type the following in Stata and then share the output using dataex. There is a tutorial on using dataex on Youtube here
      Code:
      dataex country_code country code firm_id company year SID_code CSR_var // obviously change to names of your variables
      Code:
      * I tried to clean up the data you shared in #8
      dataex country_code country code firm_id company year SID_code
      clear
      input byte country_code str8 country str7 code byte firm_id str19 company int(year SID_code)
      1 "China"    "CN:BEL"  1 "BOE TECHNOLOGY"      2015 3679
      1 "China"    "CN:BEL"  1 "BOE TECHNOLOGY"      2016 3679
      1 "China"    "CN:BEL"  1 "BOE TECHNOLOGY"      2017 3679
      1 "China"    "CN:CCWH" 2 "SOUTHWEST SECURI"    2015 6231
      1 "China"    "CN:CCWH" 2 "SOUTHWEST SECURI"    2016 6231
      1 "China"    "CN:CCWH" 2 "SOUTHWEST SECURI"    2017 6231
      3 "India"    "In:BISH" 3 "Nestle India"        2015 3312
      3 "India"    "In:BISH" 3 "Nestle India"        2016 3312
      3 "India"    "In:BISH" 3 "Nestle India"        2017 3312
      3 "India"    "U:HDB"   4 "HDFC BANK LIMITED"   2015 6029
      3 "India"    "U:HDB"   4 "HDFC BANK LIMITED"   2016 6029
      3 "India"    "U:HDB"   4 "HDFC BANK LIMITED"   2017 6029
      5 "Pakistan" "PK:PSO"  5 "Pakistan State Oil"  2015 6231
      5 "Pakistan" "PK:PSO"  5 "Pakistan State Oil"  2016 6231
      5 "Pakistan" "PK:PSO"  5 "Pakistan State Oil"  2017 6231
      5 "Pakistan" "PK:ACB"  6 "ASKARI BANK LIMITED" 2015 6029
      5 "Pakistan" "PK:ACB"  6 "ASKARI BANK LIMITED" 2016 6029
      5 "Pakistan" "PK:ACB"  6 "ASKARI BANK LIMITED" 2017 6029
      end
      
      * I added a firm_id just to make it easier
      sort country_code firm_id year
      isid firm_id year  // it is
      duplicates tag firm_id year, gen(dups)
      list, sepby(firm_id) abbrev(12) noobs
      
        +--------------------------------------------------------------------------------------------+
        | country_code    country      code   firm_id               company   year   SID_code   dups |
        |--------------------------------------------------------------------------------------------|
        |            1      China    CN:BEL         1        BOE TECHNOLOGY   2015       3679      0 |
        |            1      China    CN:BEL         1        BOE TECHNOLOGY   2016       3679      0 |
        |            1      China    CN:BEL         1        BOE TECHNOLOGY   2017       3679      0 |
        |--------------------------------------------------------------------------------------------|
        |            1      China   CN:CCWH         2      SOUTHWEST SECURI   2015       6231      0 |
        |            1      China   CN:CCWH         2      SOUTHWEST SECURI   2016       6231      0 |
        |            1      China   CN:CCWH         2      SOUTHWEST SECURI   2017       6231      0 |
        |--------------------------------------------------------------------------------------------|
        |            3      India   In:BISH         3          Nestle India   2015       3312      0 |
        |            3      India   In:BISH         3          Nestle India   2016       3312      0 |
        |            3      India   In:BISH         3          Nestle India   2017       3312      0 |
        |--------------------------------------------------------------------------------------------|
        |            3      India     U:HDB         4     HDFC BANK LIMITED   2015       6029      0 |
        |            3      India     U:HDB         4     HDFC BANK LIMITED   2016       6029      0 |
        |            3      India     U:HDB         4     HDFC BANK LIMITED   2017       6029      0 |
        |--------------------------------------------------------------------------------------------|
        |            5   Pakistan    PK:PSO         5    Pakistan State Oil   2015       6231      0 |
        |            5   Pakistan    PK:PSO         5    Pakistan State Oil   2016       6231      0 |
        |            5   Pakistan    PK:PSO         5    Pakistan State Oil   2017       6231      0 |
        |--------------------------------------------------------------------------------------------|
        |            5   Pakistan    PK:ACB         6   ASKARI BANK LIMITED   2015       6029      0 |
        |            5   Pakistan    PK:ACB         6   ASKARI BANK LIMITED   2016       6029      0 |
        |            5   Pakistan    PK:ACB         6   ASKARI BANK LIMITED   2017       6029      0 |
        +--------------------------------------------------------------------------------------------+
      Two quick questions:
      1) If a company has multiple entries for a year, how do you want to handle those?

      2) Do companies cross countries in your data (i.e. will BOE TECHNOLOGY be listed in India and Pakistan or just China?)

      Comment


      • #18
        Hi David

        My apologies...will use dataex in future.....
        Thanks for your assistance.

        Answers to your qs:

        1) Each company has 3 years data (2015-2017) for each country. I dont get what does multiple entries mean as I dont think there are supposed to be multiple entries for each year. In other words, Co A should only be having one entry in 2015 in china.
        2)No all the companies have unique names. BOE will only be in China and not listed else where.

        Comment


        • #19
          If there is a unique firm-year observation, I cannot understand why typing egen Id=group(company_name) does not work.using dataex could you please post the variables country company and year for the entire dataset?

          Comment


          • #20
            Hi Dario

            Hi

            I just tried this command and it worked....But i am not sure if I did this right....

            . egen new_pane= group(Country company )

            . sort new_pane Years

            . xtset new_pane Years
            panel variable: new_pane (strongly balanced)
            time variable: Years, 2015 to 2017
            delta: 1 unit
            It worked with the same data. I just replaced SIC codes with company names.

            Comment

            Working...
            X