Announcement

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

  • bysort for subgroup

    My question focuses on a dataset of employees in the US. I want to generate a variable that tells me the percentage of employees with one specific characteristic (binary). I am not able to generate this variable because I would like to generate the number per company per year.

    Based on the clear company_year identifier, I was able to get the overall number of employees per firm per year:

    bysort identifier: gen Numb_Total_Employees = _N

    Unfortunately, I am now not able to generate the other number due to the fact, that I need to consider only the employees with characteristic == 1.

    Would appreciate every hint which could help!!!

  • #2
    Code:
    bysort identifier: egen Numb_have_characteristic = total(characteristic_var)

    Comment


    • #3
      Perfect, thank you very much!

      Comment

      Working...
      X