Hi all,

I have a categorical variable with three categories (1, 2, 3). I want to find the percentage share of each category per year per state. I can get the results I want if I write:

Code:
tab var if year==1977 & state==1
I was wondering if there is a loop I can make or if there is an easier way to do it because otherwise I will need to make the calculations manually every time. My range is from 1977-2018 for 51 states.

Thank you in advance for your time.

Kind regards,
Alexandros Achilleos