Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: collapse and weights

From   Tomáš Houška <>
Subject   st: collapse and weights
Date   Sun, 25 Nov 2012 09:44:29 +0100

Dear Statalist,

I have data containing weekly information on prices and quantities of
sales of several products. These products can be divided into few
groups and I would like to create for each group 1) an weighted
average weekly price for the group where weight is the amounts of sale
of each product in the group and 2) sum of sales of the products that
belong to particular group. I will end up with average price and total
sales for the given product group.

But if I use
-- collapse (sum) q (mean) price [fweight=q], by(prod_group) --
the weights get applied both to the average and the sum, which is not
correct. I havent been able to come up with a solution how to bracket
the stata command. Could someone please give me some guidance?
Thank you!
Tomas (PhD student)
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index