<?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 Apparent Bug in Hash Object since 9.4 M7 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/723516#M224526</link>
    <description>&lt;P&gt;There seems to be a bug, introduced with M7, which influences memory consumption while reading a dataset with a WHERE= dataset option.&lt;/P&gt;
&lt;P&gt;See this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options fullstimer;

data TEST_BIGDS (drop=i);
    length CHAR1 $5. CHAR2 $10. KEY $16. DATE 5.;
    format KEY $HEX32. DATE DDMMYYP10.;
    do i=1 to 16195392;
        if i le 7825 then CHAR1="FGHIJ";
        else CHAR1="ABCDE";
        CHAR2="KLMNO";
        KEY=put(i,8.);
        DATE=today();
        output;
    end;
run;

data TEST_SMALLDS;
    length CHAR3 $5. KEY $16.;
    format KEY $HEX32.;
    CHAR3="PQRST";
    do i=1 to 20000;
        KEY=put(i,8.);
        output;
    end;
run;

data HASH_LOOKUP (drop=rc);
    length CHAR2 $10. DATE 5.;
    format DATE DDMMYYP10.;
    set TEST_SMALLDS;
    if _n_ eq 1 then do;
        declare hash H (dataset: "TEST_BIGDS (where=(CHAR1 eq 'FGHIJ'))");
        H.defineKey("KEY");
        H.defineData("CHAR2","DATE");
        H.defineDone();
        call missing(CHAR2,DATE);
    end;
    rc=H.find();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Code like this suddenly crashed after upgrading from M6 to M7 (on AIX).&lt;/P&gt;
&lt;P&gt;Since we had a backup server still on M6, we could make a comparative test.&lt;/P&gt;
&lt;P&gt;This is the log from M6:&lt;/P&gt;
&lt;PRE&gt;26   data HASH_LOOKUP (drop=rc);
27       length CHAR2 $10. DATE 5.;
28       format DATE DDMMYYP10.;
29       set TEST_SMALLDS;
30       if _n_ eq 1 then do;
31           declare hash H (dataset: "TEST_BIGDS (where=(CHAR1 eq 'FGHIJ'))");
32           H.defineKey("KEY");
33           H.defineData("CHAR2","DATE");
34           H.defineDone();
35           call missing(CHAR2,DATE);
36       end;
37       rc=H.find();
38   run;

NOTE: There were 7825 observations read from the data set WORK.TEST_BIGDS.
      WHERE CHAR1='FGHIJ';
NOTE: There were 20000 observations read from the data set WORK.TEST_SMALLDS.
NOTE: The data set WORK.HASH_LOOKUP has 20000 observations and 5 variables.
NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
      real time           4.50 seconds
      user cpu time       0.28 seconds
      system cpu time     0.31 seconds
     memory              &lt;FONT color="#FF0000"&gt;1834.62k&lt;/FONT&gt;
     OS Memory           &lt;FONT color="#FF0000"&gt;12276.00k&lt;/FONT&gt;
      Timestamp           04.03.2021 05:38:31 nachm.
      Step Count                        3  Switch Count  46
      Page Faults                       1064
      Page Reclaims                     1192
      Page Swaps                        0
      Voluntary Context Switches        125
      Involuntary Context Switches      340
      Block Input Operations            0
      Block Output Operations           0
&lt;/PRE&gt;
&lt;P&gt;and this from M7:&lt;/P&gt;
&lt;PRE&gt;254        data HASH_LOOKUP (drop=rc);
255            length CHAR2 $10. DATE 5.;
256            format DATE DDMMYYP10.;
257            set TEST_SMALLDS;
258            if _n_ eq 1 then do;
259                declare hash H (dataset: "TEST_BIGDS (where=(CHAR1 eq 'FGHIJ'))");
260                H.defineKey("KEY");
261                H.defineData("CHAR2","DATE");
262                H.defineDone();
263                call missing(CHAR2,DATE);
264            end;
265            rc=H.find();
266        run;

NOTE: There were 7825 observations read from the data set WORK.TEST_BIGDS.
      WHERE CHAR1='FGHIJ';
NOTE: There were 20000 observations read from the data set WORK.TEST_SMALLDS.
NOTE: The data set WORK.HASH_LOOKUP has 20000 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           1.82 seconds
      user cpu time       0.67 seconds
      system cpu time     0.11 seconds
     memory              &lt;FONT color="#FF0000"&gt;539046.65k&lt;/FONT&gt;
     OS Memory           &lt;FONT color="#FF0000"&gt;553580.00k&lt;/FONT&gt;
      Timestamp           03/04/2021 05:34:02 PM
      Step Count                        4  Switch Count  0
      Page Faults                       0
      Page Reclaims                     131388
      Page Swaps                        0
      Voluntary Context Switches        2
      Involuntary Context Switches      73
      Block Input Operations            0
      Block Output Operations           0
&lt;/PRE&gt;
&lt;P&gt;This can cause (batch) jobs to fail when the MEMSIZE is not sufficient to deal with this sudden increase.&lt;/P&gt;
&lt;P&gt;Creating an intermediate dataset with the WHERE condition is a suitable workaround for the moment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/287249"&gt;@ccaero&lt;/a&gt;&amp;nbsp;who found this and created the test.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Mar 2021 17:09:12 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-03-04T17:09:12Z</dc:date>
    <item>
      <title>Apparent Bug in Hash Object since 9.4 M7</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/723516#M224526</link>
      <description>&lt;P&gt;There seems to be a bug, introduced with M7, which influences memory consumption while reading a dataset with a WHERE= dataset option.&lt;/P&gt;
&lt;P&gt;See this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options fullstimer;

data TEST_BIGDS (drop=i);
    length CHAR1 $5. CHAR2 $10. KEY $16. DATE 5.;
    format KEY $HEX32. DATE DDMMYYP10.;
    do i=1 to 16195392;
        if i le 7825 then CHAR1="FGHIJ";
        else CHAR1="ABCDE";
        CHAR2="KLMNO";
        KEY=put(i,8.);
        DATE=today();
        output;
    end;
run;

data TEST_SMALLDS;
    length CHAR3 $5. KEY $16.;
    format KEY $HEX32.;
    CHAR3="PQRST";
    do i=1 to 20000;
        KEY=put(i,8.);
        output;
    end;
run;

data HASH_LOOKUP (drop=rc);
    length CHAR2 $10. DATE 5.;
    format DATE DDMMYYP10.;
    set TEST_SMALLDS;
    if _n_ eq 1 then do;
        declare hash H (dataset: "TEST_BIGDS (where=(CHAR1 eq 'FGHIJ'))");
        H.defineKey("KEY");
        H.defineData("CHAR2","DATE");
        H.defineDone();
        call missing(CHAR2,DATE);
    end;
    rc=H.find();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Code like this suddenly crashed after upgrading from M6 to M7 (on AIX).&lt;/P&gt;
&lt;P&gt;Since we had a backup server still on M6, we could make a comparative test.&lt;/P&gt;
&lt;P&gt;This is the log from M6:&lt;/P&gt;
&lt;PRE&gt;26   data HASH_LOOKUP (drop=rc);
27       length CHAR2 $10. DATE 5.;
28       format DATE DDMMYYP10.;
29       set TEST_SMALLDS;
30       if _n_ eq 1 then do;
31           declare hash H (dataset: "TEST_BIGDS (where=(CHAR1 eq 'FGHIJ'))");
32           H.defineKey("KEY");
33           H.defineData("CHAR2","DATE");
34           H.defineDone();
35           call missing(CHAR2,DATE);
36       end;
37       rc=H.find();
38   run;

NOTE: There were 7825 observations read from the data set WORK.TEST_BIGDS.
      WHERE CHAR1='FGHIJ';
NOTE: There were 20000 observations read from the data set WORK.TEST_SMALLDS.
NOTE: The data set WORK.HASH_LOOKUP has 20000 observations and 5 variables.
NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
      real time           4.50 seconds
      user cpu time       0.28 seconds
      system cpu time     0.31 seconds
     memory              &lt;FONT color="#FF0000"&gt;1834.62k&lt;/FONT&gt;
     OS Memory           &lt;FONT color="#FF0000"&gt;12276.00k&lt;/FONT&gt;
      Timestamp           04.03.2021 05:38:31 nachm.
      Step Count                        3  Switch Count  46
      Page Faults                       1064
      Page Reclaims                     1192
      Page Swaps                        0
      Voluntary Context Switches        125
      Involuntary Context Switches      340
      Block Input Operations            0
      Block Output Operations           0
&lt;/PRE&gt;
&lt;P&gt;and this from M7:&lt;/P&gt;
&lt;PRE&gt;254        data HASH_LOOKUP (drop=rc);
255            length CHAR2 $10. DATE 5.;
256            format DATE DDMMYYP10.;
257            set TEST_SMALLDS;
258            if _n_ eq 1 then do;
259                declare hash H (dataset: "TEST_BIGDS (where=(CHAR1 eq 'FGHIJ'))");
260                H.defineKey("KEY");
261                H.defineData("CHAR2","DATE");
262                H.defineDone();
263                call missing(CHAR2,DATE);
264            end;
265            rc=H.find();
266        run;

NOTE: There were 7825 observations read from the data set WORK.TEST_BIGDS.
      WHERE CHAR1='FGHIJ';
NOTE: There were 20000 observations read from the data set WORK.TEST_SMALLDS.
NOTE: The data set WORK.HASH_LOOKUP has 20000 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           1.82 seconds
      user cpu time       0.67 seconds
      system cpu time     0.11 seconds
     memory              &lt;FONT color="#FF0000"&gt;539046.65k&lt;/FONT&gt;
     OS Memory           &lt;FONT color="#FF0000"&gt;553580.00k&lt;/FONT&gt;
      Timestamp           03/04/2021 05:34:02 PM
      Step Count                        4  Switch Count  0
      Page Faults                       0
      Page Reclaims                     131388
      Page Swaps                        0
      Voluntary Context Switches        2
      Involuntary Context Switches      73
      Block Input Operations            0
      Block Output Operations           0
&lt;/PRE&gt;
&lt;P&gt;This can cause (batch) jobs to fail when the MEMSIZE is not sufficient to deal with this sudden increase.&lt;/P&gt;
&lt;P&gt;Creating an intermediate dataset with the WHERE condition is a suitable workaround for the moment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/287249"&gt;@ccaero&lt;/a&gt;&amp;nbsp;who found this and created the test.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 17:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/723516#M224526</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-04T17:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Bug in Hash Object since 9.4 M7</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/723526#M224528</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has this been reported to SAS Tech Support? If not, I'll be happy to open a track for it.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 17:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/723526#M224528</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2021-03-04T17:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Bug in Hash Object since 9.4 M7</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/723795#M224669</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt; ,&lt;BR /&gt;I opened a support-track on this topic today, the ticket number is 7613295889.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 07:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/723795#M224669</guid>
      <dc:creator>ccaero</dc:creator>
      <dc:date>2021-03-05T07:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Bug in Hash Object since 9.4 M7</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/723814#M224678</link>
      <description>&lt;P&gt;It would be nice if others who have already upgraded to M7 could check this on other platforms.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 09:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/723814#M224678</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-05T09:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Bug in Hash Object since 9.4 M7</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/731901#M228027</link>
      <description>What was the outcome of the track ?</description>
      <pubDate>Wed, 07 Apr 2021 13:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/731901#M228027</guid>
      <dc:creator>raks2301</dc:creator>
      <dc:date>2021-04-07T13:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Bug in Hash Object since 9.4 M7</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/731902#M228028</link>
      <description>&lt;P&gt;Whats the outcome of the track?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 13:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/731902#M228028</guid>
      <dc:creator>raks2301</dc:creator>
      <dc:date>2021-04-07T13:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Bug in Hash Object since 9.4 M7</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/731906#M228029</link>
      <description>&lt;P&gt;SAS confirmed the problem and issued a &lt;A href="https://support.sas.com/kb/67/620.html" target="_self"&gt;SAS Note 67620&amp;nbsp;&lt;/A&gt;" A hash object in SAS® 9.4M7 (TS1M7) might consume significantly more memory than it did in previous releases"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the note:&lt;/P&gt;
&lt;P&gt;This problem occurs when the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=ds2ref&amp;amp;docsetTarget=n03n4ipuouac35n136fdcrccdao9.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;HASHEXP method&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is not specified when defining the hash object. The amount of memory that is allocated can vary, depending on the data within the defined hash.&lt;/P&gt;
&lt;P&gt;The workaround is to define the hash object with the HASHEXP method, as illustrated by the syntax fragment below:&lt;/P&gt;
&lt;DIV&gt;&lt;LI-CODE lang="sas"&gt;data HASH_LOOKUP;
&amp;nbsp; &amp;nbsp;if&amp;nbsp;_n_ eq 1 then&amp;nbsp;do;
&amp;nbsp; &amp;nbsp;declare hash H (dataset:&amp;nbsp;"TEST_DSET (where=(CHAR1 eq&amp;nbsp;'ABCDE'))",HASHEXP:8);
&amp;nbsp; &amp;nbsp;...more code...&lt;/LI-CODE&gt;&lt;/DIV&gt;
&lt;P&gt;If the HASHEXP method is not specified in the declaration, a default value of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is used. However, specifying&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;HASHEXP:8&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(the default) in the DECLARE statement will dramatically reduce the step memory footprint than not coding the method. The value for the HASHEXP method depends on usage. It is recommended that you test different values to find the optimal value for each case.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 13:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Bug-in-Hash-Object-since-9-4-M7/m-p/731906#M228029</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2021-04-07T13:45:58Z</dc:date>
    </item>
  </channel>
</rss>

