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

## Re: Net Groups of Lines in a Table to \$0.00

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.

Obsidian | Level 7

## Re: Net Groups of Lines in a Table to \$0.00

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.

Tourmaline | Level 20

## Re: Net Groups of Lines in a Table to \$0.00

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

Discussion stats
• 17 replies
• 1719 views
• 4 likes
• 8 in conversation