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!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 2 replies
  • 735 views
  • 1 like
  • 2 in conversation