<?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: Hash object with Insufficient memory to execute data step program in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440612#M110106</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1.table3 (drop=rc);
length Abstract $32767 Behavior $1 Comment $32767 Grade $1 Histology $4 Laterality $1 Site $4 TEST $20 ;

declare hash hh();
rc=hh.definekey('ID');
rc=hh.definedata('AbsrefID', 'Abstract', 'Behavior', 'Comment', 'DATEUPDATED', 'Grade', 'Histology', 'Laterality', 'ID', 'Site', 'TEST');
rc=hh.definedone();

do until (eof1);
set test1.table1 end=eof1;
rc = hh.add();
END;

DO UNTIL (eof2);
SET test2.table2 END=eof2;
rc = hh.find();
IF rc EQ 0 THEN OUTPUT;
end;
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;LOG:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;ERROR: Hash object added 1572848 items when memory failure occurred.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;FATAL: Insufficient memory to execute DATA step program. Aborted during the EXECUTION phase.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;ERROR: The SAS System stopped processing this step because of insufficient memory.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;NOTE: There were 1572850 observations read from the data set test1.table1.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;NOTE: There were 1 observations read from the data set test2.table2.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;WARNING: The data set test1.table3 may be incomplete. When this step was stopped&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#FF6600"&gt;there were 0 observations and 27 variables.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Feb 2018 18:03:53 GMT</pubDate>
    <dc:creator>DeepakSwain</dc:creator>
    <dc:date>2018-02-27T18:03:53Z</dc:date>
    <item>
      <title>Hash object with Insufficient memory to execute data step program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440515#M110044</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order to get the benefit of hash object programming for look up, I am trying to get a subset of a data having 3 million records based on the records with unique identifier present in another table with 1.3 million records. While doing so, getting an error message :&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;Insufficient memory to data step program. The SAS system stopped processing this step because of insufficient memory.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Can anybody suggest me to overcome the error or an alternative means to improve efficiency.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Thank you in advance for your kind reply.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 14:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440515#M110044</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2018-02-27T14:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Hash object with Insufficient memory to execute data step program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440518#M110045</link>
      <description>&lt;P&gt;Show us your code&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 14:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440518#M110045</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-02-27T14:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Hash object with Insufficient memory to execute data step program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440542#M110059</link>
      <description>&lt;P&gt;Impossible to suggest something without seeing the code and some knowledge about the data and setup of your sas environment. For the later please execute&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc options group=memory;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and post the result using {i} icon.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 16:05:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440542#M110059</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-02-27T16:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Hash object with Insufficient memory to execute data step program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440612#M110106</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1.table3 (drop=rc);
length Abstract $32767 Behavior $1 Comment $32767 Grade $1 Histology $4 Laterality $1 Site $4 TEST $20 ;

declare hash hh();
rc=hh.definekey('ID');
rc=hh.definedata('AbsrefID', 'Abstract', 'Behavior', 'Comment', 'DATEUPDATED', 'Grade', 'Histology', 'Laterality', 'ID', 'Site', 'TEST');
rc=hh.definedone();

do until (eof1);
set test1.table1 end=eof1;
rc = hh.add();
END;

DO UNTIL (eof2);
SET test2.table2 END=eof2;
rc = hh.find();
IF rc EQ 0 THEN OUTPUT;
end;
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;LOG:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;ERROR: Hash object added 1572848 items when memory failure occurred.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;FATAL: Insufficient memory to execute DATA step program. Aborted during the EXECUTION phase.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;ERROR: The SAS System stopped processing this step because of insufficient memory.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;NOTE: There were 1572850 observations read from the data set test1.table1.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;NOTE: There were 1 observations read from the data set test2.table2.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;WARNING: The data set test1.table3 may be incomplete. When this step was stopped&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#FF6600"&gt;there were 0 observations and 27 variables.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 18:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440612#M110106</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2018-02-27T18:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Hash object with Insufficient memory to execute data step program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440614#M110108</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;options&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;group&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;memory&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;LOG shows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;SAS (r) Proprietary Software Release 9.4 TS1M3&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;Group=MEMORY&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;SORTSIZE=1073741824&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;Specifies the amount of memory that is available to the SORT procedure.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;SUMSIZE=0 Specifies a limit on the amount of memory that is available for data&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;summarization procedures when class variables are active.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;MAXMEMQUERY=0 Specifies the maximum amount of memory that is allocated for procedures.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;MEMBLKSZ=16777216 Specifies the memory block size for Windows memory-based libraries.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;MEMMAXSZ=2147483648&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;Specifies the maximum amount of memory to allocate for using memory-based&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;libraries.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;LOADMEMSIZE=0 Specifies a suggested amount of memory that is needed for executable&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;programs loaded by SAS.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;MEMSIZE=107213322240&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;Specifies the limit on the amount of virtual memory that can be used during&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;a SAS session.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;REALMEMSIZE=0 Specifies the amount of real memory SAS can expect to allocate.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;NOTE: PROCEDURE OPTIONS used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;real time 0.01 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;cpu time 0.01 seconds&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 18:08:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440614#M110108</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2018-02-27T18:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Hash object with Insufficient memory to execute data step program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440615#M110109</link>
      <description>1. Please do not use the table with transaction data(heavier tables) as hash table.&lt;BR /&gt;2. The hash is called hash mapping. So mapping tables are used as hash tables.&lt;BR /&gt;3. Your program is crashing because, a certain amount of space is allocated for HASH tables, which is breached. We used SQL and indexes instead when we had these issues.</description>
      <pubDate>Tue, 27 Feb 2018 18:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440615#M110109</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-02-27T18:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Hash object with Insufficient memory to execute data step program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440641#M110122</link>
      <description>&lt;P&gt;You want to match records in table1 and table2 by id, and keep only those with id's in both tables, by using a hash object for table 1.&amp;nbsp; Your program assumes there is only 1 record per ID in table1.&amp;nbsp; It makes no assumption about table 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You ran into a memory problem storing table 1 into a hash object.&amp;nbsp; There are two solutions: (1) increase memory available to the program, or (2) reduce memory demanded by hash.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Increase memory&lt;BR /&gt;On my windows machine, if I run "proc options group=memory;run;" as suggested by others, it shows "memsize=2147483648"&amp;nbsp; (2 gigabytes).&amp;nbsp;&amp;nbsp; You could start your sas session with more memory.&amp;nbsp; For instance, if I click on the Start button and type&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "sas -memsize 4g"&lt;BR /&gt;I have double the memory.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Decreasing hash memory demands.&amp;nbsp;
&lt;OL&gt;
&lt;LI&gt;If table2 requires less memory than table1 and has only 1 observations per ID, then reverse the roles of table 1 and table 2.&amp;nbsp; How do you determine the memory required?&amp;nbsp;&amp;nbsp; Load a single record into the object (termed a single "data item" in hash lexicon), get the itemsize attribute&amp;nbsp;&amp;nbsp; ("bytes_per_item=hh.itemsize;") and multiply by the number of unique ID's.&lt;BR /&gt;&lt;BR /&gt;By the way, I would not ADD one record at a time.&amp;nbsp; Instead use this declare&amp;nbsp;statement&amp;nbsp;to load it all at once:&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;declare hash hh(dataset:"table1 (keep=abserfid abstract behavior comment dateupdated grade histology laterality id site test)");
  hh.definekey ('ID');
  hh.definedata(all:'Y');
  hh.definedone();
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Still too much memory needed?&amp;nbsp; You could then use the hash object merely as a pointer to a record id that could then be used in a "set .... POINT= " statement, as here (untested).&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data rid /view=rid;  /* Make pointers - record IDs*/
   set table1 (keep=id );
   rid=_n_;
run;

data want;
   if _n_=1 then declare hash hh (dataset:'rid');
      hh.definekey('id');
      hh.definedata(all:'Y');
      hh.definedone();
   end;
   set table2;
   rc=hh.find();
   if rc=0;
   set table1 (keep=id abstract behavior ......) point=rid;
run;      &lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 12 Oct 2020 16:11:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440641#M110122</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-10-12T16:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Hash object with Insufficient memory to execute data step program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440649#M110126</link>
      <description>&lt;P&gt;Your table TABLE1 contains 2 variables with 32KB length so no wonder you run out of memory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's in your table TABLE2? If this one is smaller then may-be load this one into the hash. And if the relationship between your tables is one-to-many then use the multidata option in the declare statement and the do_over() method when reading from the hash.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And just FYI: If you just want to load a table into a hash then you don't need to loop over the table but you can load it directly using code like: dcl hash hh(dataset:'test1.table1'); ....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 20:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-object-with-Insufficient-memory-to-execute-data-step/m-p/440649#M110126</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-02-27T20:06:28Z</dc:date>
    </item>
  </channel>
</rss>

