BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ChrisHemedinger
Community Manager
If VARDEF is what you're looking for, here's the example from SAS doc: https://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#n1xkqt7u5ylr2kn11174...

You will need to read through it to see if you can apply that to your situation.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Rick_SAS
SAS Super FREQ

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.

 

twildone
Pyrite | Level 9

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;;

EH
Obsidian | Level 7 EH
Obsidian | Level 7
Hello Twildone,
You are right about the "makes no sense" part. This is "a sort of weighted average", it is the average yearly premium. If you multiply that by the number of weights (fractions) you get the total received premium.
In proc means, the weighted average is calculated as sum(WiXi)/sum(Wi), where my "sort of" requires sum(Xi)/sum(Wi). I am afraid I have to calculate this outside proc means, as suggested by others. Thanks anyway for your thoughts!
EH
Obsidian | Level 7 EH
Obsidian | Level 7
And thanks to this simple question, since friday I received five (5) badges. I'm so happy 🙂

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 19 replies
  • 3186 views
  • 8 likes
  • 5 in conversation