<?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: Deleting a hash object and reusing the object reference variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61355#M13325</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I must be missing something here.&amp;nbsp; (Running SAS 9.1.3 on PC).&amp;nbsp; The sequence for using hash objects is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;declare hash h;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Tell data step compiler h is a reference to some hash object ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;h = _new_ hash();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create an instance of hash object, store its pointer in h ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineKey('k');&amp;nbsp;&amp;nbsp; * Define actual hash object structure ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineData('d');&amp;nbsp; * Define actual hash object structure ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineDone();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.add();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.find();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = r.remove();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.delete();&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * The memory structures of the hash object is released, h now is an invalid reference ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;/*&amp;nbsp;&amp;nbsp; You can then define another hash object and use h to refer to it:&amp;nbsp; */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;h = _new_ hash();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * h now again point to an empty hash object;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineKey('p');&amp;nbsp;&amp;nbsp; * Define actual hash object structure ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineData('q');&amp;nbsp; * Define actual hash object structure ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineDone();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.add();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.find();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = r.remove();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.delete();&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Release the hash object, h is no longer a valid hash reference;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;If you want to have macro independence, you should&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- use different names for the hash tables,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- control when to release each hash object&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;This way the hash objects won't collide with each other.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;However, if you want to have just one name for all the hash object, meaning you'll never need to use more than one of them at a time, you should&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- declare the hash reference one time, (as above... only a single declare statement)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- use _new_, defineKey(), defineData(), ... to create/instantiate and use the object&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- when done, use delete() to remove the object from memory&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- use _new_ again to define another hash object, perhaps with a different structure, but can still use h to point to it&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- delete() when it's not needed any more&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Note that if you use h = _new_ hash() without first using h.delete(), the object h was pointing to is now "pointerless" and you will have no way to refer to it, unless you have another reference pointing to it.&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;The thing to remember is to separate "objects" from "pointers or references"... these are dynamic objects, not static.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;In the macros above, the hash objects are created and destroyed by the macro.&amp;nbsp; So when the macro finishes, there are no hash objects left for you to use.&amp;nbsp; No?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Sep 2011 18:05:22 GMT</pubDate>
    <dc:creator>DLing</dc:creator>
    <dc:date>2011-09-09T18:05:22Z</dc:date>
    <item>
      <title>Deleting a hash object and reusing the object reference variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61350#M13320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS 9.2 on Windows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm writing a macro dealing with hash objects, and would like to reuse the hash object variable for multiple hash objects in the same data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The doc for the DELETE() method says:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA step component objects are deleted automatically at the end of the DATA step. &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; If you want to reuse the object reference variable in another hash or hash iterator object constructor, you should delete the hash or hash iterator object by using the DELETE method. &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone explain what the &amp;gt;&amp;gt;&amp;gt; emphasized &amp;lt;&amp;lt;&amp;lt; text means???&amp;nbsp; What exactly does the DELETE() method buy me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is the "declare hash" statement a compile time or execution time statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is test code which illustrates my problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro do_something_with_hash(key,data);&lt;/P&gt;&lt;P&gt;&amp;nbsp; declare hash h();&lt;/P&gt;&lt;P&gt;&amp;nbsp; h.defineKey("&amp;amp;key");&lt;/P&gt;&lt;P&gt;&amp;nbsp; h.defineData("&amp;amp;data");&lt;/P&gt;&lt;P&gt;&amp;nbsp; h.defineDone();&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc=h.delete();&lt;/P&gt;&lt;P&gt;&amp;nbsp; put rc=;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length foo bar 8;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; * this works ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do_something_with_hash(foo,bar)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; * but a second invocation fails ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do_something_with_hash(blah,blech)&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 07:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61350#M13320</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2011-09-07T07:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting a hash object and reusing the object reference variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61351#M13321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-top: auto; margin-bottom: auto;"&gt;&lt;STRONG style="font-size: 24pt; font-family: 'Times New Roman','serif';"&gt;_NEW_ Operator, Hash or Hash Iterator Object&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; do_something_with_hash(key,data);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: green; font-family: 'Courier New'; background-color: white;"&gt;*object-reference = _NEW_ object(&amp;lt;argument_tag-1: value-1&amp;lt;, ...argument_tag-n: value-n&amp;gt;&amp;gt;);&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; h = _new_ hash();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; h.defineKey(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;"&amp;amp;key"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; h.defineData(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;"&amp;amp;data"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; h.defineDone();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; rc=h.delete();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; put rc=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;options&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;mprint&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; foo bar blah blech &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;8&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;declare&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; hash h;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: green; font-family: 'Courier New'; background-color: white;"&gt;* this works ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; %&lt;STRONG&gt;&lt;EM&gt;do_something_with_hash&lt;/EM&gt;&lt;/STRONG&gt;(foo,bar)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: green; font-family: 'Courier New'; background-color: white;"&gt;* and so does this;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; %&lt;STRONG&gt;&lt;EM&gt;do_something_with_hash&lt;/EM&gt;&lt;/STRONG&gt;(blah,blech)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 11:46:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61351#M13321</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-09-07T11:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting a hash object and reusing the object reference variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61352#M13322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Mr. Null,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was hoping the macro would be "self contained", i.e. I wouldn't have to declare hash h outside the macro.&amp;nbsp; (This actual code where this is used is actually much more complicated).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 11:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61352#M13322</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2011-09-07T11:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting a hash object and reusing the object reference variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61353#M13323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course the answer is simple "create a called flag".&amp;nbsp; Making sure if is removed without a warning, which you will complain about, is a bit fiddly but still doable.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would be interested know more about your "much more complicated" program, as I can't see how deleting and redefining a hash will be very helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: &amp;amp;quot;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; do_something_with_hash(key,data);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;%global&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &amp;amp;sysmacroname;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;%if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;%superQ&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;(&amp;amp;sysmacroname) eq &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;%then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;declare hash h;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &amp;amp;sysmacroname = called;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;%else&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;call execute(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: purple; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;'%nrstr(%sysfunc(ifC(%sysfunc(symexist('&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;||&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: purple; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;"&amp;amp;sysmacroname"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;||&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: purple; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;')),%nrstr(%symdel '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;||&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: purple; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;"&amp;amp;sysmacroname"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;||&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: purple; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;';),%nrstr(%put NOTE: Already Done;))))'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: green; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;*object-reference = _NEW_ object(&amp;lt;argument_tag-1: value-1&amp;lt;, ...argument_tag-n: value-n&amp;gt;&amp;gt;);&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;h = _new_ hash();&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;h.defineKey(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: purple; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;"&amp;amp;key"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;h.defineData(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: purple; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;"&amp;amp;data"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;h.defineDone();&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;rc=h.delete();&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: &amp;amp;quot;"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;options&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;mprint&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: &amp;amp;quot;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: &amp;amp;quot;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; foo bar blah blech &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: &amp;amp;quot;"&gt;8&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: green; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;* this works ;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;%&lt;STRONG&gt;&lt;EM&gt;do_something_with_hash&lt;/EM&gt;&lt;/STRONG&gt;(foo,bar)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: green; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;* and so does this;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;%&lt;STRONG&gt;&lt;EM&gt;do_something_with_hash&lt;/EM&gt;&lt;/STRONG&gt;(blah,blech)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;%&lt;STRONG&gt;&lt;EM&gt;do_something_with_hash&lt;/EM&gt;&lt;/STRONG&gt;(blah,blech)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 0pt; line-height: normal; mso-layout-grid-align: none;"&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;&lt;SPAN style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;%&lt;STRONG&gt;&lt;EM&gt;do_something_with_hash&lt;/EM&gt;&lt;/STRONG&gt;(blah,blech)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal" style="margin: 0in 0in 10pt;"&gt;&lt;SPAN style="line-height: 115%; color: black; font-size: 10pt; background: white; mso-spacerun: yes; font-family: &amp;amp;quot;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="line-height: 115%; color: navy; background: white; font-size: 10pt; font-family: &amp;amp;quot;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; line-height: 115%; font-family: &amp;amp;quot;Courier New&amp;amp;quot;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I realized that my SYMDEL bit is too complicated.&amp;nbsp; The SYMDEL should be done ONCE when the called flag is created.&amp;nbsp; Using NRSTR will delay executioning until after the data step is done.&amp;nbsp; Plus if the macro is only called once the called flag still needs to be SYMDELed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; do_something_with_hash(key,data);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%global&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &amp;amp;sysmacroname;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%if&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%superQ&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;(&amp;amp;sysmacroname) eq &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare hash h;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &amp;amp;sysmacroname = called;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;'%nrstr(%symdel '&lt;/SPAN&gt;||&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;"&amp;amp;sysmacroname"&lt;/SPAN&gt;||&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;';)'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: green; font-family: 'Courier New'; background-color: white;"&gt;*object-reference = _NEW_ object(&amp;lt;argument_tag-1: value-1&amp;lt;, ...argument_tag-n: value-n&amp;gt;&amp;gt;);&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; h = _new_ hash();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; h.defineKey(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;"&amp;amp;key"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; h.defineData(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;"&amp;amp;data"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; h.defineDone();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; rc=h.delete();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;options&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;mprint&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; foo bar blah blech &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;8&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: green; font-family: 'Courier New'; background-color: white;"&gt;* this works ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; %&lt;STRONG&gt;&lt;EM&gt;do_something_with_hash&lt;/EM&gt;&lt;/STRONG&gt;(foo,bar)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: green; font-family: 'Courier New'; background-color: white;"&gt;* and so does this;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; %&lt;STRONG&gt;&lt;EM&gt;do_something_with_hash&lt;/EM&gt;&lt;/STRONG&gt;(blah,blech)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; %&lt;STRONG&gt;&lt;EM&gt;do_something_with_hash&lt;/EM&gt;&lt;/STRONG&gt;(blah,blech)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; %&lt;STRONG&gt;&lt;EM&gt;do_something_with_hash&lt;/EM&gt;&lt;/STRONG&gt;(blah,blech)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 13:07:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61353#M13323</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-09-07T13:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting a hash object and reusing the object reference variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61354#M13324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Because you have the same Hash object reference,so you can not use it twice ,since they point actually the same Hash Object.&lt;/P&gt;&lt;P&gt;You can use Null 's suggestion to create new Hash Object reference _new_ hash();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Sep 2011 09:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61354#M13324</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-09-09T09:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting a hash object and reusing the object reference variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61355#M13325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I must be missing something here.&amp;nbsp; (Running SAS 9.1.3 on PC).&amp;nbsp; The sequence for using hash objects is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;declare hash h;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Tell data step compiler h is a reference to some hash object ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;h = _new_ hash();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create an instance of hash object, store its pointer in h ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineKey('k');&amp;nbsp;&amp;nbsp; * Define actual hash object structure ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineData('d');&amp;nbsp; * Define actual hash object structure ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineDone();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.add();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.find();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = r.remove();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.delete();&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * The memory structures of the hash object is released, h now is an invalid reference ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;/*&amp;nbsp;&amp;nbsp; You can then define another hash object and use h to refer to it:&amp;nbsp; */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;h = _new_ hash();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * h now again point to an empty hash object;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineKey('p');&amp;nbsp;&amp;nbsp; * Define actual hash object structure ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineData('q');&amp;nbsp; * Define actual hash object structure ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.defineDone();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.add();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.find();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = r.remove();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;rc = h.delete();&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Release the hash object, h is no longer a valid hash reference;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;If you want to have macro independence, you should&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- use different names for the hash tables,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- control when to release each hash object&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;This way the hash objects won't collide with each other.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;However, if you want to have just one name for all the hash object, meaning you'll never need to use more than one of them at a time, you should&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- declare the hash reference one time, (as above... only a single declare statement)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- use _new_, defineKey(), defineData(), ... to create/instantiate and use the object&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- when done, use delete() to remove the object from memory&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- use _new_ again to define another hash object, perhaps with a different structure, but can still use h to point to it&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;- delete() when it's not needed any more&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Note that if you use h = _new_ hash() without first using h.delete(), the object h was pointing to is now "pointerless" and you will have no way to refer to it, unless you have another reference pointing to it.&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;The thing to remember is to separate "objects" from "pointers or references"... these are dynamic objects, not static.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;In the macros above, the hash objects are created and destroyed by the macro.&amp;nbsp; So when the macro finishes, there are no hash objects left for you to use.&amp;nbsp; No?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Sep 2011 18:05:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61355#M13325</guid>
      <dc:creator>DLing</dc:creator>
      <dc:date>2011-09-09T18:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting a hash object and reusing the object reference variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61356#M13326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With dynamic data structures, the reference or pointer to it, is very distinct from the memory location or object itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;declare hash H;&amp;nbsp;&amp;nbsp; is a compile time statement, saying H will contain references to hash objects, but does not create the object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;declare hash H Q;&amp;nbsp;&amp;nbsp; says H and Q are hash references, does not create objects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;declare hash H();&amp;nbsp;&amp;nbsp;&amp;nbsp; says H is a reference to hash objects, and creates an empty hash object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;H = _new_ hash();&amp;nbsp;&amp;nbsp;&amp;nbsp; creates an empty hash object, and stores its address in H.&amp;nbsp; H now is a reference to the object.&amp;nbsp; If H previously pointed to another valid hash object, H now no longer points to it, example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare hash H;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H is a pointer to hash objects&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H = _new_ hash();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create an object.&amp;nbsp; Store its address in H.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H = _new_ hash();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create another object.&amp;nbsp; Store its address in H.&amp;nbsp; The previous object still exist, but H doesn't point to it.&amp;nbsp; It is orphaned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Multiple reference to same object:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare hash H Q;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H and Q are pointers to hash objects.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H = _new_ hash();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create an object.&amp;nbsp; H points to it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Q = H;&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; Q now also point to the same hash object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;H.delete();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deletes the object H points to.&amp;nbsp; But H, the pointer itself, is not deleted.&amp;nbsp; You can use it to point to another hash object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare hash H;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H = _new_ hash();&amp;nbsp;&amp;nbsp;&amp;nbsp; create object #1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H.delete();&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; delete object #1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H = _new_ hash();&amp;nbsp;&amp;nbsp;&amp;nbsp; create object #2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H.delete();&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; delete object #2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ahh, the fun and games with object oriented programming.&amp;nbsp; Never thought it'd show up in a SAS data step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Sep 2011 21:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61356#M13326</guid>
      <dc:creator>DLing</dc:creator>
      <dc:date>2011-09-09T21:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting a hash object and reusing the object reference variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61357#M13327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe I'm missing something too...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A trivial example to illustrate:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro create_a_variable(value=);&lt;/P&gt;&lt;P&gt;attrib myvar length=8 format=best. label="My Variable";&lt;/P&gt;&lt;P&gt;myvar=&amp;amp;value;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;%create_a_variable(value=1);&lt;/P&gt;&lt;P&gt;%create_a_variable(value=2);&lt;/P&gt;&lt;P&gt;%create_a_variable(value=3);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The macro is "self-contained" - all required variables are declared ***within the macro*** via attrib, and I don't have to keep a flag when myvar is "declared".&amp;nbsp; %create_a_variable executes an attrib statement, which is a compile time option.&amp;nbsp; Now, I know myvar gets specified three times during compilation, and last setting wins, but I don't get an error when I try to redefine myvar, esp. when the attributes are the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So why do I get an error when I try to declare hash h multiple times in the data step?&amp;nbsp; No, I wouldn't do this in open code, but it just makes life easier (and consistent with other aspects of SAS) if I don't get a compile time error if I execute "declare hash h" multiple times within a generic macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are there technical reasons, or object oriented programming convention, that caused SAS to write the software this way?&amp;nbsp; Or is it just the way they decided to do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apologies if I'm just being dense...it happens occasionally.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2011 08:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61357#M13327</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2011-09-29T08:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting a hash object and reusing the object reference variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61358#M13328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're not being dense, you raised a very good point.&amp;nbsp; You got me on that one, I don't understand why SAS did it that way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you said, multiple attrib statements, last one wins, no compile time messages generated.&amp;nbsp; But a redundant declare hash that is syntactically identical does generate an error message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps ask SAS to "fix" it, or help us understand the situations where multiple declare hash would causes issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: DLing to fix grammar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2011 13:28:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-a-hash-object-and-reusing-the-object-reference-variable/m-p/61358#M13328</guid>
      <dc:creator>DLing</dc:creator>
      <dc:date>2011-09-29T13:28:29Z</dc:date>
    </item>
  </channel>
</rss>

