The past few days I am trying to accomplish something that (I think) is probably simple, but I can not seem to do it. I read through the manual, but that also did not give me what I want. I hope that someone can share his/her expertise with me.
I have the following dataset
Code:
input str12 CompanyID int Year byte Awards str2 Gender "1111" 2018 6 "M" "2222" 2018 5 "F" "1111" 2018 15 "F" "1111" 2019 7 "F" "3333" 2014 25 "M" "4444" 2017 12 "M" "2222" 2011 13 "F"
Code:
bysort CompanyID Year: egen AwardsTotal = sum(Award)
However, I cannot seem to manage to only do this for the gender "F". In the case of CompanyID 111 for the year 2018, my code gives me 21, while I actually want 6 (since the other entry is for the Male gender).
Does someone have an idea how to do this? I hope I made it clear enough. If it is not, please let me know and I will try to clarify.
Best regards,
Ferry
0 Response to Simple question about counting in specific cases
Post a Comment