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]
Re: st: collapse and weights
From
Austin Nichols <[email protected]>
To
[email protected]
Subject
Re: st: collapse and weights
Date
Mon, 26 Nov 2012 18:36:28 +0100
Tomáš Houška <[email protected]>:
Your goal is a bit hard to understand from the description--are you
saying you want the sum of q and the q-weighted mean of price?
Like:
g one=1
collapse (sum) sum=one (mean) price [fweight=q], by(prod_group)
On Sun, Nov 25, 2012 at 9:44 AM, Tomáš Houška <[email protected]> wrote:
> 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/