Then, I collapsed the dataset by summing up the price x units and units variables: collapse (sum) pricexunits units, by(week product)Īnd finally, I created a new variable where I divided pricexunits by units. So what I did is I manually calculated a new variable price x units in the original data set. Cox Department of Geography Durham University Durham, UK n.j.coxdurham.ac. 565569 Stata tip 111: More on working with weeks Nicholas J. ![]() The data set is a collection of single transactions with # of purchases and prices per unit paid at week/store/product level: clearĬlearly, taking simple averages when collapsing ignores number of units purchased, resulting in a wrong average price estimate. The Stata Journal (2012) 12, Number 3, pp. It means that I am not able to get weighted average prices paid in my sales data set at a week/product level where the weight is the units sold. I couldn't find a Stata command on the following issue, so I solved it manually:Īccording to the official manual, Stata doesn't do weights with averages in the collapse command (p.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |