<?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: How to workout keep track the variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/582533#M165694</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134236"&gt;@sagulolo&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;As noted earlier, I'd expect the array to be faster than the hash - in this &lt;EM&gt;particular&lt;/EM&gt; situation and for the reasons already stated.&lt;/P&gt;
&lt;P&gt;However, truth be told, a real speed comparison test should involve more than a thousand or so records. When both methods being compared run under 0.03 seconds, it's difficult to attribute the difference between the run times shown in the log to the methods themselves rather than to a myriad of always existing confounding factors (such as other processes running on the same machine concurrently with SAS).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Aug 2019 18:39:15 GMT</pubDate>
    <dc:creator>hashman</dc:creator>
    <dc:date>2019-08-20T18:39:15Z</dc:date>
    <item>
      <title>How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578325#M164001</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have 2 table which is&amp;nbsp;Table_A and&amp;nbsp;Table_B,&amp;nbsp;Table_A&amp;nbsp; extra number will always sufficient to cover the short number at&amp;nbsp;Table_B. The logic will be use the extra number from Table A to knock off the first short number from Table B with to the same group(Sg_a =&amp;nbsp;Sg_b) until zero then follow by second short number from the same group. Please refer below:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data Table_A;
  infile datalines dlm='|';
  input  Sg_a $ Key_a $ extra;
;
datalines;
A |KEY1  |50
A |KEY2  |80
B |KEY6  |1000
C |KEY9  |10
C |KEY10 |5
C |KEY11 |500
;

data Table_B;
  infile datalines dlm='|';
  input  Sg_b $ Key_b $ short;
;
datalines;
A |KEY3  |10
A |KEY4  |25
A |KEY5  |35
B |KEY7  |200
B |KEY8  |700
C |KEY12 |20
C |KEY13 |400
C |KEY14 |10
C |KEY15 |50
;

proc sql;
	create table rightjoin as
	select a.*, b.*
	from Table_A a right join
	Table_B b
	on a.Sg_a = b.Sg_b;
quit;&lt;/PRE&gt;&lt;P&gt;So far, I have tried to right join table A to table B, but have no idea how to evaluate and keep track the actual_transfer, below is my desire output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Sg_a&lt;/TD&gt;&lt;TD&gt;Key_a&lt;/TD&gt;&lt;TD&gt;Key_b&lt;/TD&gt;&lt;TD&gt;actual_transfer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY1&lt;/TD&gt;&lt;TD&gt;KEY3&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY1&lt;/TD&gt;&lt;TD&gt;KEY4&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY1&lt;/TD&gt;&lt;TD&gt;KEY5&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY2&lt;/TD&gt;&lt;TD&gt;KEY5&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;KEY6&lt;/TD&gt;&lt;TD&gt;KEY7&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;KEY6&lt;/TD&gt;&lt;TD&gt;KEY8&lt;/TD&gt;&lt;TD&gt;700&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY9&lt;/TD&gt;&lt;TD&gt;KEY12&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY10&lt;/TD&gt;&lt;TD&gt;KEY12&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY12&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY13&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY14&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY15&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your time and help on this matter.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 13:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578325#M164001</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2019-08-02T13:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578337#M164007</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The logic will be use the extra number from Table A to knock off the first short number from Table B with to the same group(Sg_a =&amp;nbsp;Sg_b) until zero then follow by second short number from the same group. Please refer below:-&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you explain how you got "actual_transfer"&amp;nbsp; using sg_a and sg_b? I am bad to understand your term "to knock off".&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 11:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578337#M164007</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-08-01T11:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578341#M164009</link>
      <description>&lt;P&gt;Hi datasp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank for your time and sorry for my bad english,&amp;nbsp; please refer below:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A KEY1(table A) --&amp;gt; extra 50&amp;nbsp; - A KEY3(table B) short 10&amp;nbsp; (50 - 10, can offset 10), so i get below:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i output A KEY1(table A)&amp;nbsp; A KEY3(table B)&amp;nbsp;10, then&amp;nbsp;A KEY1(table A) -&amp;gt; still have extra $40&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A KEY1(table A) --&amp;gt; extra 40 -&amp;nbsp;A KEY4(table B) short 25&amp;nbsp;(40 - 25, can offset 25)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i output A KEY1(table A)&amp;nbsp; A KEY4(table B) 25, then&amp;nbsp;A KEY1(table A) -&amp;gt; still have extra 15&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A KEY1(table A) --&amp;gt; extra 15 -&amp;nbsp;A KEY5(table B) short 35 (15 - 35, only can offset 15)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i output A KEY1(table A)&amp;nbsp; A KEY5(table B) 15, then next i refer to A KEY2 80 for the balance of&amp;nbsp; A KEY5(table B) which is 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A KEY2 (table A) --&amp;gt;extra&amp;nbsp; 80 -&amp;nbsp;A KEY5(table B) short 20 ( 80 - 20, can offset 20)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i output&amp;nbsp;A KEY2 (table A)&amp;nbsp;&amp;nbsp;A KEY5(table B) short 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope the above clarifies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 11:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578341#M164009</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2019-08-01T11:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578373#M164026</link>
      <description>&lt;P&gt;Hi datasp,&lt;BR /&gt;&lt;BR /&gt;Apologize as didn't really answer your question.&lt;BR /&gt;"actual_transfer" is refer to sg_b if table A extra more than sg_b short. Else will be sg_a balance left.&lt;BR /&gt;&lt;BR /&gt;Once the table B short all deducted then move to next B then C.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 12:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578373#M164026</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2019-08-01T12:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578439#M164060</link>
      <description>&lt;P&gt;I understand for the first A of Table 1 and you cross compare&amp;nbsp; EXTRA with SHORT. This goes like 10, 25, and final residual (15) replaces 35 of SHORT.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Once the table B short all deducted then move to next B then C.&lt;/PRE&gt;
&lt;P&gt;What is happening the next A of Table1? Is it to be ignored and go to B of Table 1?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You show the output on your revised specification. In your output append comment in the form of Balance_Extra = 50 - 10, 40 - 25 , 15 - 15 for each row. It will be easy to know what you want.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 14:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578439#M164060</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-08-01T14:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578698#M164173</link>
      <description>&lt;P&gt;Hi datasp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologize for late reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is happening the next A of Table1?&lt;/P&gt;&lt;P&gt;no action require as Table_B no more A group&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it to be ignored and go to B of Table 1?&lt;/P&gt;&lt;P&gt;Yes, next will be cross match between Table_A and Table_B for B group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Added balance_extra into table for more understanding, thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Sg_a&lt;/TD&gt;&lt;TD&gt;Key_a&lt;/TD&gt;&lt;TD&gt;Key_b&lt;/TD&gt;&lt;TD&gt;Balance_Extra&lt;/TD&gt;&lt;TD&gt;actual_transfer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY1&lt;/TD&gt;&lt;TD&gt;KEY3&lt;/TD&gt;&lt;TD&gt;50 -10 = 40&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY1&lt;/TD&gt;&lt;TD&gt;KEY4&lt;/TD&gt;&lt;TD&gt;40 - 25 = 15&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY1&lt;/TD&gt;&lt;TD&gt;KEY5&lt;/TD&gt;&lt;TD&gt;15 - 15 = 0(Key 1 no more number, next use Key 2)&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY2&lt;/TD&gt;&lt;TD&gt;KEY5&lt;/TD&gt;&lt;TD&gt;80 - 20,&amp;nbsp; stop as table_B no more group for A&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;KEY6&lt;/TD&gt;&lt;TD&gt;KEY7&lt;/TD&gt;&lt;TD&gt;1000 - 200 = 800&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;KEY6&lt;/TD&gt;&lt;TD&gt;KEY8&lt;/TD&gt;&lt;TD&gt;800 - 700 = 100, stop as table_B no more group for B&lt;/TD&gt;&lt;TD&gt;700&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY9&lt;/TD&gt;&lt;TD&gt;KEY12&lt;/TD&gt;&lt;TD&gt;10 - 10 = 0, (Key 9 no more number, next use Key 10)&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY10&lt;/TD&gt;&lt;TD&gt;KEY12&lt;/TD&gt;&lt;TD&gt;5 - 5 = 0, (Key 10 no more number, next use Key 11)&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY12&lt;/TD&gt;&lt;TD&gt;500 - 5 = 495&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY13&lt;/TD&gt;&lt;TD&gt;495 - 400 = 95&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY14&lt;/TD&gt;&lt;TD&gt;95 - 10 = 85&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY15&lt;/TD&gt;&lt;TD&gt;85 - 50 = 35,&amp;nbsp; stop for as table_B no more group for C&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 02 Aug 2019 13:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578698#M164173</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2019-08-02T13:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578727#M164179</link>
      <description>&lt;P&gt;It is good now. I want the 'desired output'. Place the revised output.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 14:50:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578727#M164179</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-08-02T14:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578738#M164183</link>
      <description>&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Sg_a&lt;/TD&gt;
&lt;TD&gt;Key_a&lt;/TD&gt;
&lt;TD&gt;Key_b&lt;/TD&gt;
&lt;TD&gt;Balance_Extra&lt;/TD&gt;
&lt;TD&gt;actual_transfer&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;KEY1&lt;/TD&gt;
&lt;TD&gt;KEY3&lt;/TD&gt;
&lt;TD&gt;50 -10 = 40&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;KEY1&lt;/TD&gt;
&lt;TD&gt;KEY4&lt;/TD&gt;
&lt;TD&gt;40 - 25 = 15&lt;/TD&gt;
&lt;TD&gt;25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;KEY1&lt;/TD&gt;
&lt;TD&gt;KEY5&lt;/TD&gt;
&lt;TD&gt;15 - 15 = 0(Key 1 no more number, next use Key 2)&lt;/TD&gt;
&lt;TD&gt;15&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;KEY2&lt;/TD&gt;
&lt;TD&gt;KEY5&lt;/TD&gt;
&lt;TD&gt;80 - 20,&amp;nbsp; stop as table_B no more group for A&lt;/TD&gt;
&lt;TD&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;KEY6&lt;/TD&gt;
&lt;TD&gt;KEY7&lt;/TD&gt;
&lt;TD&gt;1000 - 200 = 800&lt;/TD&gt;
&lt;TD&gt;200&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;KEY6&lt;/TD&gt;
&lt;TD&gt;KEY8&lt;/TD&gt;
&lt;TD&gt;800 - 700 = 100, stop as table_B no more group for B&lt;/TD&gt;
&lt;TD&gt;700&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;KEY9&lt;/TD&gt;
&lt;TD&gt;KEY12&lt;/TD&gt;
&lt;TD&gt;10 - 10 = 0, (Key 9 no more number, next use Key 10)&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;KEY10&lt;/TD&gt;
&lt;TD&gt;KEY12&lt;/TD&gt;
&lt;TD&gt;5 - 5 = 0, (Key 10 no more number, next use Key 11)&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;KEY11&lt;/TD&gt;
&lt;TD&gt;KEY12&lt;/TD&gt;
&lt;TD&gt;500 - 5 = 495&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;KEY11&lt;/TD&gt;
&lt;TD&gt;KEY13&lt;/TD&gt;
&lt;TD&gt;495 - 400 = 95&lt;/TD&gt;
&lt;TD&gt;400&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;KEY11&lt;/TD&gt;
&lt;TD&gt;KEY14&lt;/TD&gt;
&lt;TD&gt;95 - 10 = 85&lt;/TD&gt;
&lt;TD&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;KEY11&lt;/TD&gt;
&lt;TD&gt;KEY15&lt;/TD&gt;
&lt;TD&gt;85 - 50 = 35,&amp;nbsp; stop for as table_B no more group for C&lt;/TD&gt;
&lt;TD&gt;50&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5th row in 500 - 5, how do you get this 5? See In Table_B, k12 is 20.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 15:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578738#M164183</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-08-02T15:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578768#M164199</link>
      <description>&lt;P&gt;Hi datasp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The desire output will be as per below:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Sg_a&lt;/TD&gt;&lt;TD&gt;Key_a&lt;/TD&gt;&lt;TD&gt;Key_b&lt;/TD&gt;&lt;TD&gt;actual_transfer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY1&lt;/TD&gt;&lt;TD&gt;KEY3&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY1&lt;/TD&gt;&lt;TD&gt;KEY4&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY1&lt;/TD&gt;&lt;TD&gt;KEY5&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;KEY2&lt;/TD&gt;&lt;TD&gt;KEY5&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;KEY6&lt;/TD&gt;&lt;TD&gt;KEY7&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;KEY6&lt;/TD&gt;&lt;TD&gt;KEY8&lt;/TD&gt;&lt;TD&gt;700&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY9&lt;/TD&gt;&lt;TD&gt;KEY12&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY10&lt;/TD&gt;&lt;TD&gt;KEY12&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY12&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY13&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY14&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;KEY11&lt;/TD&gt;&lt;TD&gt;KEY15&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 16:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578768#M164199</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2019-08-02T16:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578771#M164202</link>
      <description>&lt;P&gt;Hi datasp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5th row in 500 - 5, how do you get this 5? See In Table_B, k12 is 20.&lt;/P&gt;&lt;P&gt;I get the output 5 is because&lt;/P&gt;&lt;P&gt;20 - 10 - 5 (KEY12 - KEY9 - KEY10) = 5, so need another 5 from KEY 11 to become zero.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 16:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578771#M164202</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2019-08-02T16:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578784#M164212</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134236"&gt;@sagulolo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you insist on SQL solution? I have no sql-head. I am trying Data Step approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are problems in getting :&lt;/P&gt;
&lt;P&gt;A Key2 Key5 20 as Key5 has been used in the previous row of output.&lt;/P&gt;
&lt;P&gt;Similarly, with:&lt;/P&gt;
&lt;P&gt;C Key9 Key12 10&lt;/P&gt;
&lt;P&gt;C Key10 Key12 5&lt;/P&gt;
&lt;P&gt;C Key11 Key12 5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking into this. Be patient.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 17:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578784#M164212</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-08-02T17:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578785#M164213</link>
      <description>&lt;P&gt;Hi datasp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm okay with the data step approach and really thank for looking into this matter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 17:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/578785#M164213</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2019-08-02T17:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/579239#M164402</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134236"&gt;@sagulolo&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;A curious puzzle. Frankly, I've spent about 90% of my time having a crack at it by trying to understand your spec. However, it's commendable that you've tried harder every next iteration, and finally it's helped. Once the pattern was clear, writing the code was fairly easy. One selection that had to be made was to decide on the type of a lookup table for the info from Table_A, and I have finally opted, somewhat contrary to my moniker, for using arrays - primarily since they are simple to update in place.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the code (the input tables are assumed sorted by SG_A and SG_B, respectively):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Table_A ;                                                                 
  input  Sg_a $ Key_a $ extra ;                                                
  cards ;                                                                      
A KEY1    50                                                                   
A KEY2    80                                                                   
B KEY6  1000                                                                   
C KEY9    10                                                                   
C KEY10   05                                                                   
C KEY11  500                                                                   
run ;                                                                          
                                                                               
data Table_B;                                                                  
  input  Sg_b $ Key_b $ short ;                                                
  cards ;                                                                      
A KEY3   10                                                                    
A KEY4   25                                                                    
A KEY5   35                                                                    
B KEY7  200                                                                    
B KEY8  700                                                                    
C KEY12  20                                                                    
C KEY13 400                                                                    
C KEY14  10                                                                    
C KEY15  50                                                                    
run ;                                                                          
                                                                               
proc sql noprint ;                                                             
  select max (d) into :d from (select count (*) as d from table_a group sg_a) ;
quit ;                                                                         
                                                                               
data want (keep = sg_a key_a key_b balance_extra actual_transfer) ;            
  array x [&amp;amp;d]   8 _temporary_ ;                                               
  array k [&amp;amp;d] $ 8 _temporary_ ;                                               
  do _i = 1 by 1 until (last.sg_a) ;                                           
    set table_a (in = _a) table_b (rename = sg_b = sg_a);                      
    by sg_a ;                                                                  
    if _a then do ;                                                            
      x [_i] = extra ;                                                         
      k [_i] = key_a ;                                                         
      _im = _i ;                                                               
    end ;                                                                      
    else do _i = 1 by 0 until (short = 0 or _i &amp;gt; _im) ;                        
      actual_transfer = x [_i] min short ;                                     
      if actual_transfer &amp;gt; 0 then do ;                                         
        key_a = k [_i] ;                                                       
        balance_extra = x [_i] - actual_transfer ;                             
        output ;                                                               
      end ;                                                                    
      x [_i] +- actual_transfer ;                                              
      short  +- actual_transfer ;                                              
      if x [_i] = 0 then _i + 1 ;                                              
    end ;                                                                      
  end ;                                                                        
run ;                                                                          
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The preliminary SQL step is used to size their upper bound at the expense of an extra pass through Table_A. Alternatively, you can omit the step and instead of setting the upper bounds of the arrays X and K to &amp;amp;D, set them to something "big enough" like 99999. The only requirement to its magnitude is that it must be equal to or exceed the size of the largest BY group by SG_A in Table_A. Yet another alternative is to use a hash table instead of the arrays; but in this case methinks that compared to the arrays, it would introduce an extra level of complexity with regard to accessing the lookup items and updating them in place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the different note, I don't see how this nut can be cracked without procedural programming and by using SQL alone.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2019 22:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/579239#M164402</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-05T22:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/579408#M164470</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you so much for the coding, this is what I need and I never though of array can solve this puzzle. Now I have to test it at my real data, nevertheless apologize for my bad english. I will update here again after I test it with the real data.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17813"&gt;@KachiM&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;Really appreciate your giving comments on the lack of logic explanations and guiding me to write a explanation to get the desire result. I also don't mind if you share others solution as I still new and lack of logical mind to resolve issue/puzzle like this.&lt;BR /&gt;&lt;BR /&gt;Best regards</description>
      <pubDate>Tue, 06 Aug 2019 14:59:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/579408#M164470</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2019-08-06T14:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/579424#M164481</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have spent several hours on solving this problem. I am still testing another data step approach. With&amp;nbsp; struggles I had, I will say yours is a program of excellence. It must be a case study to every aspiring Data Step Programmers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134236"&gt;@sagulolo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Initially I thought it is simply a many to many and one to many merging problem. There is a twist. In the middle of Table_B, we need to go to Table_A to get some info and return to the place in Table_B to continue. This jump_return-continue&amp;nbsp; is the crucial part of programming. This is first time for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Enjoy the array solution given by Paul D. If you have Data step debugger and if you like, understand the flow of the program and visualize&amp;nbsp; the&amp;nbsp; values of variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best wishes&lt;/P&gt;
&lt;P&gt;DataSP&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 15:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/579424#M164481</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-08-06T15:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/579521#M164498</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134236"&gt;@sagulolo&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;Thanks for the kind words.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WRT the essence of the task, the principal issue is the programming algorithm. It goes more or less like this:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Read the next (i.e. in the beginning, the first) BY group from Table_A 1 record at a time, giving each the next value of _i+1. If no records in the file are left to read, STOP.&lt;/LI&gt;
&lt;LI&gt;Store EXTRA and KEY_A from each record in (some sort of) lookup table in memory whose items can be (i) accessed by the item number as a key and (ii) updated using the item number as a key. This key is simply the sequential number _i.&lt;/LI&gt;
&lt;LI&gt;Read the next (i.e. at the beginning, the first) BY group from Table_B. If no records in the file are left to read, STOP. For each record from this BY group:&lt;/LI&gt;
&lt;LI&gt;Set _i to 1 and extract the item with _i=1 from the lookup table.&lt;/LI&gt;
&lt;LI&gt;Compute actual_transfer as the minimum between SHORT and the value of EXTRA extracted from the table.&lt;/LI&gt;
&lt;LI&gt;If actual_transfer &amp;gt; 0 then compute&amp;nbsp;balance_extra = extra - actual_transfer, then output.&lt;/LI&gt;
&lt;LI&gt;Subtract actual_transfer from EXTRA, then subtract actual_transfer from SHORT.&lt;/LI&gt;
&lt;LI&gt;Update the table for the current value of _i with the new value of EXTRA, keeping KEY_A in the table intact.&lt;/LI&gt;
&lt;LI&gt;If EXTRA=0, then we need to grab the next item from the table, so increment _i by 1. Then go to 5.&lt;/LI&gt;
&lt;LI&gt;After the last record from Table_B has been processed, clear the lookup table (unless measures are taken to overwrite its items).&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see, which kind of lookup table to choose is a matter of the programmer's discretion and/or familiarity with different SAS tools. Arrays items are naturally accessed by index (in this case, _i) and easy to update directly in place. Alternatively, a hash table can be used, whose advantage is that, unlike with an array, you needn't muck around determining its maximum size beforehand since it grows automatically when the next item is added. The disadvantage is that you cannot update a data portion variable directly in the table: Instead, you need to first extract its value into its PDV host variable (by calling the FIND method), set it to the desired value, and then update the table (by calling the REPLACE method). Or, in the SAS language:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep = sg_a key_a key_b balance_extra actual_transfer) ;
  if _n_ = 1 then do ;                                             
    dcl hash h () ;                                                
    h.definekey ("_i") ;                                           
    h.definedata ("extra", "key_a") ;                              
    h.definedone () ;                                              
  end ;                                                            
  do _i = 1 by 1 until (last.sg_a) ;                               
    set table_a (in = _a) table_b (rename = sg_b = sg_a);          
    by sg_a ;                                                      
    if _a then h.add() ;                                           
    else do _i = 1 by 0 until (short = 0 or _i &amp;gt; h.num_items) ;    
      h.find() ;                                                   
      actual_transfer = extra min short ;                          
      if actual_transfer &amp;gt; 0 then do ;                             
        balance_extra = extra - actual_transfer ;                  
        output ;                                                   
      end ;                                                        
      extra +- actual_transfer ;                                   
      short +- actual_transfer ;                                   
      h.replace() ;                                                
      if extra = 0 then _i + 1 ;                                   
    end ;                                                          
  end ;                                                            
  h.clear() ;                                                      
run ;                                                              
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that with the array solution, we needn't clear the array content before each next BY group because when it is loaded from it, its _iM first items get overwritten, and the further balance transfer processing occurs only up to _iM.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul M.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 22:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/579521#M164498</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-06T22:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/579917#M164675</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17813"&gt;@KachiM&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank for another tips - Data step debugger as this is first time I hear this, just have a googling on this and this is way better visual than to remove the noprint and cancel those drop to understand the flow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Deepest apologies for late reply, when I test the first solution(array), you have already share the 2nd solution(hash method) and even further explain the logical idea of solving this puzzle. The array was work perfectly, I will test the 2nd solution tomorrow and will compare the time consume for both solution. Then I will share the time spend for each solution and to confirm the best solution(actually not sure if i doing the fair comparison, thinking of using the same real data and just compare the time spend).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 15:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/579917#M164675</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2019-08-08T15:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/582369#M165638</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17813"&gt;@KachiM&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My deepest apologies for delay as I couldn't make it last Friday before I have my long leave. Below is my tested results,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1486 observations read from the data set WORK.TABLE_A.&lt;BR /&gt;1007 observations read from the data set WORK.TABLE_B.&lt;/P&gt;&lt;P&gt;Total of 2493 observations only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hash Method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: There were 1486 observations read from the data set WORK.TABLE_A.&lt;BR /&gt;NOTE: There were 1007 observations read from the data set WORK.TABLE_B.&lt;BR /&gt;NOTE: The data set WORK.WANT has 1085 observations and 5 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Array Method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: There were 1486 observations read from the data set WORK.TABLE_A.&lt;BR /&gt;NOTE: There were 1007 observations read from the data set WORK.TABLE_B.&lt;BR /&gt;NOTE: The data set WORK.WANT has 1085 observations and 5 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the above time, I can say the array method is faster than Hash method. However, i wish i can choose both as solution because both also produce the same observation numbers(sorry didn't have time to check all),&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this will benefit others also, I'm also welcome others expert to provide other solution and comments as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank again for both your time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 10:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/582369#M165638</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2019-08-20T10:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to workout keep track the variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/582533#M165694</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134236"&gt;@sagulolo&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;As noted earlier, I'd expect the array to be faster than the hash - in this &lt;EM&gt;particular&lt;/EM&gt; situation and for the reasons already stated.&lt;/P&gt;
&lt;P&gt;However, truth be told, a real speed comparison test should involve more than a thousand or so records. When both methods being compared run under 0.03 seconds, it's difficult to attribute the difference between the run times shown in the log to the methods themselves rather than to a myriad of always existing confounding factors (such as other processes running on the same machine concurrently with SAS).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 18:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-workout-keep-track-the-variable/m-p/582533#M165694</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-20T18:39:15Z</dc:date>
    </item>
  </channel>
</rss>

