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

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).

idvar1var2wtAR_Q0AR_Q1AR_Q2AR_Q3AR_Q4AR_Q5
1xx3450.5101112131415
1xx3450.3505152535455
1xx3450.2202122232425
2df3210.7303132333435
2df3210.1404142434445
2df3210.2505152535455

 

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

 

idvar1var2AR_Q0AR_Q1AR_Q2AR_Q3AR_Q4AR_Q5
1xx345242526272829
2df321353637383940

 

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.

 

Thanks in advance.

1 ACCEPTED SOLUTION

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

View solution in original post

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

Thanks Paige!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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