You will need to read through it to see if you can apply that to your situation.
Fine with me. You can use any formula you want.
One reason you won't find this in a SAS procedure is that it is not a mean (weighted or otherwise). In terms of terminology, I would call the formula sum(x)/sum(y) a scaled sum. Notice that if you reorder the weight values, you will get the same scaled sum. The "fraction" values are not attached to the "premium" values in any way, so you'll get the same answer for
1 0.5 1000
2 1 500
and for
1 -99 1000
2 100.5 500
Good luck with your analysis.
Hi Eric,
Using Sum(premium)/Sum(Fraction) will not give you the right answer if you are wanting to calculated a weighted average where the weights are the fraction of the year that a premium was paid. From your original example, the Sum(Premium) = 900 + 600 =1500 and Sum(Fraction) = 1.0 + 0.5 = 1.5. As a result, 1500/1.5 = 1000. How can the average of the two premiums be more than either one of them ( 900 or 600). This makes no sense.
If you sum up the product of the premium and fraction and then divide by the sum of the fraction that will and should give you a weighted average for the two premiums ((1.0)(900) +(0.5)(600))/(1.0 + 0.5) = 1200/ 1.5 = 800.
proc sql;
select sum(premium*fraction)/sum(fraction) as mean_premium
from premium;
quit;;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.