Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Braunfels, Philipp (Stud. SBE / Alumni)" <P.Braunfels@student.maastrichtuniversity.nl> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
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/