Announcement

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

  • #16
    Maybe the case is best illustrated with an example.
    Code:
    clear
    input employeeID Year IndustryCode companyId
    1 2000 20 1
    1 2001 20 2
    1 2002 20 1
    2 2000 20 1
    2 2001 30 3
    2 2002 20 1
    end
    
    bysort employeeID IndustryCode (Year): gen tag = companyId != companyId[_n-1] & _n > 1
    * first code
    bysort employeeID companyId: egen probably_not_wanted = max(tag)
    
    * second code
    bysort employeeID IndustryCode (Year): gen wanted = sum(tag) >= 1
    sort employeeID Year
    list, noobs abbr(20) sepby(employeeID)
    
      +-----------------------------------------------------------------------------------+
      | employeeID   Year   IndustryCode   companyId   tag   probably_not_wanted   wanted |
      |-----------------------------------------------------------------------------------|
      |          1   2000             20           1     0                     1        0 |
      |          1   2001             20           2     1                     1        1 |
      |          1   2002             20           1     1                     1        1 |
      |-----------------------------------------------------------------------------------|
      |          2   2000             20           1     0                     0        0 |
      |          2   2001             30           3     0                     0        0 |
      |          2   2002             20           1     0                     0        0 |
      +-----------------------------------------------------------------------------------+
    The two codes generate different results for employee 1 in 2000, which i think should not be coded as being a specialist. Only the second code does this properly.

    Another case to consider is employee 2. Is someone a specialist when returning to the same firm after working in another firm from another industry? If so, you will need different code.

    Comment


    • #17
      Got it. Thank you very much!

      Comment


      • #18
        Hello again...
        I am happy with the following code
        Code:
        bysort employeeID IndustryCode (Year): gen tag = companyId != companyId[_n-1] & _n > 1
        bysort employeeID IndustryCode (Year): gen wanted = sum(tag) >= 1
        However, I realised that some employees may have two or more positions in more than one firm in the same year (and so may work in more than one industry). Is this is going to make any difference in terms of the code?

        Comment


        • #19
          No, no difference at all.

          Comment


          • #20
            Thanks!

            Comment

            Working...
            X