I have a dataset that looks like the following:
year Gender VP
2023 Total 3
2023 F 2
2023 M 1
2022 Total 6
2022 F 4
2022 M 2
2021 Total 2
...
What I want to do is generate a variable VP_per
that gives me the female percentage of VPs for every year.
Basically something that looks like
bysort year gender : gen VP_per = VP if gender==1 / VP if gender==2
where 1 is the numeric value for Female and 2 is the numeric value for Total.