Hi Everyone,
I have a variable and has numeric values stored in it.I want to create the groups of those values whose sum is equal irrespective of number of values in each group. For eg,
T is a variable that has all the values:
T
1
2
3
4
5
6
7
Creating two groups of 14 each, the groups formed would be (1,3,4,6) and (2,5,7).
Kindly provide a generalized solution or idea because the variable actually has millions of rows.
Thanks.
"I want to group them into 10 groups"
This kind-of contradicts your initial statement where you're looking for combinations with the same sum.
With millions of values the number of possible combinations to test will exceed the computational power of your environment.
It feels like you should get back to the drawing board and try to come up with an algorithm that gives you a desired result with a different/amended method which requires less computing.
You could also try and explain here in detail the underlying problem you want to solve, what you have and what you need. There might be other ways to approach things and someone here might have solved a similar problem before.
Yeah. It is impossible mission . There are too many solutions to suit your condition .
But if you have SAS/OR ,maybe give it a try (I also doubt due to big data).
Post is at OR forum and calling @RobPratt
How precisely do they need to match?
Sort by descending value.
Assign the next value to the group with smaller current total.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.