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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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