Dear folks,

I am currently working on a dataset that contains sales data of items in stores across the country. Each row represents a purchase and contains information on the amount of product name, product brand, units sold, unit price, date, store name, store brand, state of store, etc. For the sake of price analysis, I am currently trying to create a mean price across the whole observational period. However, as prices obviously differ across brands, store types and time, one has to create several individual means that control for each of these variable specifications.
More precisely:

I want Stata to create individual mean prices for each of all observations that share:

The same product (variable 1)
The same store type (variable 2)
The same state of store (variable 3)
The same week of purchase (variable 4)
The same year of purchase (variable 5)

I have some working knowledge with creating new variables, means, etc. in Stata. However, I haven't managed to do get it done if the mean depends on more than one variable as in the case above.

Many thanks in advance!