I have data similar to the below where I am looking at the products sold in stores over 3 years:
Store Name | Product | Year | Store_Product |
Tesco | Biscuits | 2010 | 1 |
Tesco | Biscuits | 2011 | 1 |
Tesco | Biscuits | 2012 | 1 |
Tesco | Water Bottles | 2010 | 2 |
Tesco | Water Bottles | 2011 | 2 |
Tesco | Cakes | 2010 | 3 |
Tesco | Cakes | 2011 | 3 |
Asda | Biscuits | 2010 | 4 |
Asda | Biscuits | 2011 | 4 |
Asda | Water Bottles | 2010 | 5 |
Asda | Cakes | 2010 | 6 |
Asda | Cakes | 2011 | 6 |
Asda | Cakes | 2012 | 6 |
Sainsburys | Water Bottles | 2010 | 7 |
Sainsburys | Water Bottles | 2011 | 7 |
Sainsburys | Water Bottles | 2012 | 7 |
Sainsburys | Cakes | 2010 | 8 |
Sainsburys | Cakes | 2011 | 8 |
Sainsburys | Cakes | 2012 | 8 |
Morrisons | Biscuits | 2011 | 9 |
Morrisons | Biscuits | 2011 | 9 |
Morrisons | Water Bottles | 2010 | 10 |
Morrisons | Cakes | 2011 | 11 |
Store_Product is a new variable I have made that combines the store name and product and gives these a unique identifier. For example Biscuits in Tesco would be a combination, Biscuits in Asda would be a different combination and so on.
I want to see how many times these combinations are observed based on the time column. For example, store_product combination 1 is observed 3 times (Tesco Biscuits in 2010, 2011 and 2012), whilst store_product combination 2 is observed twice (Tesco Water Bottles 2010, 2011). I was able to obtain this via "tab product year" however this results in a long table. I`m aware of the totals after manually adding in Excel but is there a simpler way to bring this up in Stata please?
Thank you!
0 Response to Simpler way to count observation count of a variable?
Post a Comment