I think this is a simple question. I have a categorical variable (85 departments) in a long data set with multiple years/department. I use by, sort, & egen to calculate the % male in each department. However, I only want to use 1 year. How do I code that?

Right now I have
by department female, sort: generate male = _N
by department: generate percentmale = 100 * male / _N

thank you...