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

I had started to program a somewhat similar approach (starting with singletons, then pairs, triples, then I gave it up because it seemed to me that the number of combinations to check might grow too large -- depending on the data, though). I used the CALL ALLCOMBI routine rather than nested DO loops to create the combinations.

 

Not sure where the "potential of not getting everything assigned to a group" should come from: Since the original dataset has a total of zero, the leftover after taking away any proper subset with sum zero must have a total of zero as well. So, the worst case I could imagine was that at some point the remaining (not further decomposable) subset would be unnecessarily large.

adornodj
Obsidian | Level 7

Everyone -THANK YOU.  I'm implementing and trying both the "brute force" and the "greedy" applications. I sincerely cannot thank the community enough for the help on this.  I was pulling my hair out trying to figure this out, so from the bottom of my grateful heart thank you.  

ChrisNZ
Tourmaline | Level 20

You can replace the pair search with something simpler.


data work.pairs ( keep=iout jout ival jval)
     work.leftover (keep=ba:)
;
   set work.trans end=last;
   array b ba:;
   do i= 1 to (dim(b)-1);
     if b[i]=. then continue;
     j=whichn(-b[i],of b[*]);
     if j=0 then continue;
     iout=i;
     jout=j;
     ival = b[i];
     jval = b[j];
     output work.pairs2
     call missing(b[i],b[j],iout,jout);
   end;
  
   if last then output work.leftover;
run;

Not that it makes difference overall....

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 17 replies
  • 2495 views
  • 4 likes
  • 8 in conversation