Hi all,

I have a data in the following format. I need to calculate the market share where market share would be simply percentage of sales of the brand in the given year and market. For example, A in the table should be Sales of Brand 1 in year 2000 and market 1 to Total sales in year 2000 and market 1. This should be 56 / (56 + 25). Similarly, B should be (34 / (34+54+43) ). Finally, C should be (47/ (47+43)). Any coding help for such problem is much appreciated.
Year Market Brand Sales Market Share
2000 1 1 56 A
2001 1 1 34 B
2002 1 1 45
2001 1 2 54
2002 1 2 46
2000 1 3 25
2001 1 3 43
2002 1 3 41
2000 2 1 47 C
2001 2 1 65
2002 2 1 62
2001 2 2 21
2002 2 2 43
2000 2 3 43