<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SUM BASED ON ROW BY ROW in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666411#M199383</link>
    <description>but the following flag is generating with irrespective of the logic to other loanno's as well</description>
    <pubDate>Wed, 01 Jul 2020 15:31:38 GMT</pubDate>
    <dc:creator>rohithverma</dc:creator>
    <dc:date>2020-07-01T15:31:38Z</dc:date>
    <item>
      <title>SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666339#M199345</link>
      <description>&lt;P&gt;I have a data like below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;laonno&amp;nbsp; &amp;nbsp; &amp;nbsp; debit&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; childno&amp;nbsp; credit&lt;/P&gt;
&lt;P&gt;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4162.98&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1387.66&lt;/P&gt;
&lt;P&gt;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1387.66&lt;/P&gt;
&lt;P&gt;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1387.66&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need output as when the debit sum is equals to credit sum then for those observations flag should be generated as mentioned below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;laonno&amp;nbsp; &amp;nbsp; &amp;nbsp; debit&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; childno&amp;nbsp; credit&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;flag&lt;/P&gt;
&lt;P&gt;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4162.98&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;matched&lt;/P&gt;
&lt;P&gt;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;
&lt;P&gt;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1387.66&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;matched&lt;/P&gt;
&lt;P&gt;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1387.66&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;matched&lt;/P&gt;
&lt;P&gt;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1387.66&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;matched&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data rows&amp;nbsp; will be dynamic but when the sum of debit matches credit then the following flag should be as "MATCHED" .&lt;/P&gt;
&lt;P&gt;Please help me . Thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 11:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666339#M199345</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2020-07-01T11:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666343#M199348</link>
      <description>&lt;P&gt;Please provide the data via working SAS data step code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_blank"&gt;https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 11:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666343#M199348</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-01T11:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666347#M199351</link>
      <description>&lt;P&gt;data yy;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input laonno: $ debit: childno:$ credit:;&lt;BR /&gt;datalines;&lt;/P&gt;
&lt;P&gt;1234 4162.98 . .&lt;/P&gt;
&lt;P&gt;1234 0.02 . .&lt;/P&gt;
&lt;P&gt;. . 1234 1387.66&lt;/P&gt;
&lt;P&gt;. . 1234 1387.66&lt;/P&gt;
&lt;P&gt;. . 1234 1387.66&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 12:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666347#M199351</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2020-07-01T12:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666386#M199371</link>
      <description>&lt;P&gt;Now, I'd like a better explanation of the logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems as if you are saying that if a debit matches the sum of any combination of credits, then you list this as a match. Is that correct? Do the credits have to be consecutive? Does order matter at all? Can the credits be any number of records that adds to a debit?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would help yourself immensely by providing an example that has several debits, some that have matches and some that do not.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 14:18:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666386#M199371</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-01T14:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666398#M199373</link>
      <description>&lt;P&gt;If you data is representative, here is one way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data yy;
infile datalines;
input laonno: $ debit: childno:$ credit:;
datalines;
1234 4162.98 . .
1234 0.02 . .
. . 1234 1387.66
. . 1234 1387.66
. . 1234 1387.66
run;

data want (drop=s);
    if _N_ = 1 then do;
        dcl hash h ();
        h.definekey ('childno');
        h.definedata ('s');
        h.definedone ();

        dcl hash hh ();
        hh.definekey ('laonno');
        hh.definedone ();
        
        do until (lr);
            set yy(where=(childno)) end=lr;
            if h.find() ne 0 then s = credit;
            else                  s = sum(s, credit);
            h.replace();
        end;

    end;

    set yy;
    s = .;

    if h.find(key : laonno) = 0 &amp;amp; round(s, .001) = debit then do;
        flag = 'Matched';
        hh.ref();
    end;
    else flag = 'N';

    if hh.check(key : childno) = 0 then flag = 'Matched';

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;laonno debit   childno credit    flag 
1234   4162.98 .       .         Matched 
1234   0.02    .       .         N 
.      .       1234    1387.66   Matched 
.      .       1234    1387.66   Matched 
.      .       1234    1387.66   Matched &lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Jul 2020 14:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666398#M199373</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-07-01T14:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666404#M199377</link>
      <description>if a debit matches the sum of any combination of credits, then you list this as a match - yes perfect&lt;BR /&gt;Do the credits have to be consecutive - NO .It may be in any order.&lt;BR /&gt;Does order matter at all-No order doesn't matter&lt;BR /&gt;Can the credits be any number of records that adds to a debit- yes we cant define the particular number.&lt;BR /&gt;&lt;BR /&gt;Please find the updated dataset as mentioned below :&lt;BR /&gt;&lt;BR /&gt;data yy;&lt;BR /&gt;infile datalines  ;&lt;BR /&gt;input laonno: $     debit:   childno:$  credit:;&lt;BR /&gt;datalines;&lt;BR /&gt;&lt;BR /&gt;1234       4162.98          .             .&lt;BR /&gt;&lt;BR /&gt;1234        0.02            .             .&lt;BR /&gt;&lt;BR /&gt;.           .              1234       1387.66&lt;BR /&gt;&lt;BR /&gt;.           .              1234       1387.66&lt;BR /&gt;&lt;BR /&gt;.            .             1234       1387.66&lt;BR /&gt;4567        100             .              .    &lt;BR /&gt;4567        101              .             .     &lt;BR /&gt;.             .             4567          46&lt;BR /&gt;.             .             4567          67&lt;BR /&gt;.             .             4567          54&lt;BR /&gt;7890        46             .              .    &lt;BR /&gt;7890        67              .             .     &lt;BR /&gt;7890        54            .              .    &lt;BR /&gt;.           .              7890       100&lt;BR /&gt;&lt;BR /&gt;.           .              7890       101&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;These are the possible ways which i am working on &lt;BR /&gt;&lt;BR /&gt;output::&lt;BR /&gt;data yy;&lt;BR /&gt;infile datalines  ;&lt;BR /&gt;input laonno: $     debit:   childno:$  credit: flag:$;&lt;BR /&gt;datalines;&lt;BR /&gt;&lt;BR /&gt;1234       4162.98          .             .       y&lt;BR /&gt;&lt;BR /&gt;1234        0.02            .             .        n&lt;BR /&gt;&lt;BR /&gt;.           .              1234       1387.66      y&lt;BR /&gt;&lt;BR /&gt;.           .              1234       1387.66      y&lt;BR /&gt;&lt;BR /&gt;.            .             1234       1387.66      y&lt;BR /&gt;4567        100             .              .       y   &lt;BR /&gt;4567        101              .             .       n      &lt;BR /&gt;.             .             4567          46       y&lt;BR /&gt;.             .             4567          67       n &lt;BR /&gt;.             .             4567          54       y&lt;BR /&gt;7890        46             .              .        y  &lt;BR /&gt;7890        67              .             .        n    &lt;BR /&gt;7890        54            .              .         y   &lt;BR /&gt;.           .              7890       100          y&lt;BR /&gt;&lt;BR /&gt;.           .              7890       101          n&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Jul 2020 15:10:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666404#M199377</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2020-07-01T15:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666405#M199378</link>
      <description>Thanks for posting but i need in sas please</description>
      <pubDate>Wed, 01 Jul 2020 15:11:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666405#M199378</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2020-07-01T15:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666407#M199380</link>
      <description>&lt;P&gt;I don't understand? This is SAS?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 15:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666407#M199380</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-07-01T15:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666411#M199383</link>
      <description>but the following flag is generating with irrespective of the logic to other loanno's as well</description>
      <pubDate>Wed, 01 Jul 2020 15:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666411#M199383</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2020-07-01T15:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666413#M199384</link>
      <description>&lt;P&gt;Yes, the solution by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;is a portion of SAS that uses Hash objects to perform tasks that would be difficult or impossible with other DATA step commands. As far as I can see, it would be extremely difficult or impossible to do this in a DATA step without using Hash objects.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 15:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666413#M199384</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-01T15:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666480#M199420</link>
      <description>&lt;P&gt;Could you please apply the same logic to the blow input please as i tried but i am fetching flag as wrong. So , thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data yy;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input laonno: $ debit: childno:$ credit:;&lt;BR /&gt;datalines;&lt;BR /&gt;1234 4162.98 . .&lt;BR /&gt;1234 0.02 . .&lt;BR /&gt;. . 1234 1387.66&lt;BR /&gt;. . 1234 1387.66&lt;BR /&gt;. . 1234 1387.66&lt;BR /&gt;4567 5439 . .&lt;BR /&gt;4567 1256 . .&lt;BR /&gt;. . 4567 1864.66&lt;BR /&gt;. . 4567 1864.66&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 20:38:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666480#M199420</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2020-07-01T20:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666819#M199577</link>
      <description>&lt;P&gt;How many observations do you have for your largest group of laono/&lt;SPAN&gt;childno? In this sample data your largest group for&amp;nbsp;laono has 3 debit observations.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You want to generate all possible sums of the debit/credit amount. This is possible for small data and small groups. The three numbers 46, 67 and 54 can generate 7 (2^3-1) possible sums (46, 67, 54, 113, 121, 100 and 167). The number of possible sums grows fast for more numbers. 20 numbers can generate more than 1Million sums:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    x = 20;
    y = 2**x - 1;
    put y=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Jul 2020 13:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666819#M199577</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-07-03T13:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: SUM BASED ON ROW BY ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666820#M199578</link>
      <description>&lt;P&gt;Here is an approach that gives you your desired result for relatively small groups. Set the array sizes for a and t plus the Binary10. format properly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data yy;
infile datalines ;
input laonno: $ debit: childno:$ credit:;
datalines;
1234 4162.98 .    .       
1234 0.02    .    .       
.    .       1234 1387.66 
.    .       1234 1387.66 
.    .       1234 1387.66 
4567 100     .    .       
4567 101     .    .       
.    .       4567 46      
.    .       4567 67      
.    .       4567 54      
7890 46      .    .       
7890 67      .    .       
7890 54      .    .       
.    .       7890 100     
.    .       7890 101     
;

data want (keep= laonno debit childno credit flag);

   if _N_ = 1 then do;

      array a {10} _temporary_ (10*0);
      array t (k) t1-t10;

      dcl hash deb(multidata : "Y");
      deb.definekey("laonno");
      deb.definedata("sumdeb");
      do over t;
         deb.definedata(vname(t));
      end;
      deb.definedone();

      dcl hash cre(multidata : "Y");
      cre.definekey("childno");
      cre.definedata("sumcre");
      do over t;
         cre.definedata(vname(t));
      end;
      cre.definedone();

      do until (lr);
         set yy end=lr;
         by laonno notsorted;

         if first.laonno then do;
            i=0;
            call stdize('replace', 'mult=', 0, of a[*], _N_);
         end;

         i + 1;
         if laonno then a[i] = debit;
         else           a[i] = credit;

         if last.laonno then do;
            do j = 1 to 2**dim(a) - 1;
               s = put(j, binary10.);
               sum = 0;
               do k = 1 to dim(a);
                  t   = input(char(s,k), 8.) * a[k];
                  sum = round(sum + char(s,k) * a[k], .001);
               end;
               if laonno then do;
                  sumdeb = sum; deb.add();
               end;
               if childno then do;
                  sumcre = sum; cre.add();
               end;
            end;
         end;
      end;
   end;

   set yy;
   flag = "N";
  
   if laonno then do;
      do while (deb.do_over()=0);
         if debit in t then do while (cre.do_over(key : laonno)=0);
            if sumdeb = sumcre then flag = "Y";
         end;
      end;
   end;

   if childno then do;
      do while (cre.do_over()=0);
         if credit in t then do while (deb.do_over(key : childno)=0);
            if sumcre = sumdeb then flag = "Y";
         end;
      end;
   end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;laonno debit   childno credit   flag 
1234   4162.98 1234    .        Y 
1234   0.02    1234    .        N 
1234   .       1234    1387.66  Y 
1234   .       1234    1387.66  Y 
1234   .       1234    1387.66  Y 
4567   100.00  4567    .        Y 
4567   101.00  4567    .        N 
4567   .       4567    46.00    Y 
4567   .       4567    67.00    N 
4567   .       4567    54.00    Y 
7890   46.00   7890    .        Y 
7890   67.00   7890    .        N 
7890   54.00   7890    .        Y 
7890   .       7890    100.00   Y 
7890   .       7890    101.00   N 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 14:03:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-BASED-ON-ROW-BY-ROW/m-p/666820#M199578</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-07-03T14:03:21Z</dc:date>
    </item>
  </channel>
</rss>

