Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: collapse and weights
From
Tomáš Houška <[email protected]>
To
[email protected]
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:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/