Hi,
I have the table below and I would like to reach a sum of weight for example sum(weight)=12,933 (it could be any other number I am targeting) and ideally I would like to pick the ones with the highest scores. I am wondering if there is a way of summing the column Weight till I reach 12,933 as an example.
Your help would be much appreciated. I believe nothing is impossible in the programming world :-).
Thank you
Weight | Region | score | decile |
1520 | North West | 0.80164312 | 1 |
2164 | North West | 0.71899042 | 1 |
1849 | North West | 0.57949577 | 1 |
1284 | North West | 0.36499641 | 2 |
1284 | North West | 0.35679843 | 2 |
1739 | North West | 0.27635649 | 2 |
1894 | North West | 0.26110187 | 2 |
1653 | North West | 0.21283665 | 2 |
1739 | North West | 0.10142876 | 3 |
1555 | North West | 0.08766419 | 3 |
1280 | North West | 0.08371918 | 3 |
You need to show what the expected result actually looks like.
Also what are the rules when the target cannot be reached exactly? Does Region actually have any role in the calculation/selection? How about Decile? If so, you need to describe how they impact the process.
Hi,
Thank you for coming back...
Basically I have a target volume per region like below....and each region will have weight, scores and deciles. Don't worry about decile etc , as long as I can get to the volume I need (sum of weight) that would be good....if I do a cumulative sum of weight, it doesn't work...but summing them up randomly I could reach almost my target. It doesn't have to be 100% match, as long as it is very close. Thank you
Region | Target Volume (Sum of Weight) |
East Midlands | 11,939 |
East of England | 14,070 |
London | 12,791 |
North East | 7,829 |
North West | 12,933 |
Northern Ireland | 0 |
Scotland | 14,945 |
South East | 17,597 |
South West | 14,511 |
Wales | 5,704 |
West Midlands | 14,890 |
Yorks and the Humber | 10,526 |
Total | 137,735 |
How close is "close enough"?
So how is score supposed to fit in?
You need to show what you expect the output data set to look like.
Hi Reeza,
Thank you for your suggestion, I will give it ago 🙂
And for the PROC OPTMODEL , wasn't aware of it...
Best wishes
Thank you Reeza, the link you sent me solved my problem 🙂
I've used a code that was in one of the conversations!
Best Wishes
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.