🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Quartz | Level 8

## Sumproduct and Weighting

Hi,

I have a dataset with multiple ID's that I want to reduce to unique ID's through their respective weightings.

For example, the dataset below shows ID, some additional variables required (Var1, Var2) and the weighting (wt).

 id var1 var2 wt AR_Q0 AR_Q1 AR_Q2 AR_Q3 AR_Q4 AR_Q5 1 xx 345 0.5 10 11 12 13 14 15 1 xx 345 0.3 50 51 52 53 54 55 1 xx 345 0.2 20 21 22 23 24 25 2 df 321 0.7 30 31 32 33 34 35 2 df 321 0.1 40 41 42 43 44 45 2 df 321 0.2 50 51 52 53 54 55

I need to create multiple each AR_Qx value by the weighting and sum up the rows by ID so it looks like this. For example AR_Q5 is calculated as (15*0.5)+(55*0.3)+(25*0.2)=29

 id var1 var2 AR_Q0 AR_Q1 AR_Q2 AR_Q3 AR_Q4 AR_Q5 1 xx 345 24 25 26 27 28 29 2 df 321 35 36 37 38 39 40

What is the most efficient way of performing this calculation. At the moment I am doing this in Excel.

Note: Unfortunately I am unable to modify the source dataset as it is part of another process.

1 ACCEPTED SOLUTION

Accepted Solutions
Diamond | Level 26

## Re: Sumproduct and Weighting

``````proc summary data=have;
class id;
id var1 var2;
var ar_q0-ar_q5;
weight wt;
output out=stats sum=;
run;``````
--
Paige Miller
2 REPLIES 2
Diamond | Level 26

## Re: Sumproduct and Weighting

``````proc summary data=have;
class id;
id var1 var2;
var ar_q0-ar_q5;
weight wt;
output out=stats sum=;
run;``````
--
Paige Miller
Quartz | Level 8

## Re: Sumproduct and Weighting

Thanks Paige!

Discussion stats
• 2 replies
• 735 views
• 1 like
• 2 in conversation