Bookmark and Share

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: value weighted average


From   "Braunfels, Philipp (Stud. SBE / Alumni)" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: value weighted average
Date   Sun, 29 Jul 2012 11:43:17 +0200

Hello Statlisters,
can anyone help me in calculating value weighted averages of variable X where the weights is defined by variable Y? 

ID     Y     X       Time    Group   VW-X1
1     50     1%    1990      1
2     60     2%    1990      1
3     70     3%    1990      1
6     10     4%    1990      2
....

That is, I would like to calculate the value weighted average of X in dependence to Y for group 1:

total weight group 1= 50+60+70 = 180

Value weighted X of Group 1 (VW-X1) = 50/180* 1% + 60/180*2%+70*180*3%


Is there any command that can help me achieving this goal quickly? defining separate variables for each observation and then creating a new variable (VW-X1) seems a bit time consuming to me.

thanks in advance!
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index