<?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 key replacement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/HASH-object-key-replacement/m-p/55666#M11849</link>
    <description>Are we talking about a SAS 9.2 installation?&lt;BR /&gt;
&lt;BR /&gt;
Because this feature is not available prior that version.&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
    <pubDate>Thu, 11 Feb 2010 16:06:56 GMT</pubDate>
    <dc:creator>DanielSantos</dc:creator>
    <dc:date>2010-02-11T16:06:56Z</dc:date>
    <item>
      <title>HASH object key replacement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HASH-object-key-replacement/m-p/55665#M11848</link>
      <description>Hello,&lt;BR /&gt;
I am trying to load a dataset into a hash object. &lt;BR /&gt;
I want to use the 'DUPLICATE' option in the declare statement to replace all the duplicate keys when loading from the dataset.&lt;BR /&gt;
&lt;BR /&gt;
But it gives me a warning:  "Unrecognized or missing argument tag"&lt;BR /&gt;
all other options in the declare statement like ORDERED work fine.&lt;BR /&gt;
I am running this program on SAS learning guide 4.1&lt;BR /&gt;
&lt;BR /&gt;
why is that it is not recognizing the DUPLICATE option?&lt;BR /&gt;
Here's the code:&lt;BR /&gt;
&lt;BR /&gt;
OPTIONS formdlim='#';&lt;BR /&gt;
data a;&lt;BR /&gt;
input key a b c;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 10 100 9&lt;BR /&gt;
1 20 200 8&lt;BR /&gt;
2 20 100 8&lt;BR /&gt;
3 30 100 9&lt;BR /&gt;
4 40 100 9&lt;BR /&gt;
4 20 200 8&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
Data _null_;&lt;BR /&gt;
If _N_ = 1 then do;&lt;BR /&gt;
Declare hash H(dataset: 'work.a',&lt;B&gt;duplicate:'replace'&lt;/B&gt;, ordered:'d');&lt;BR /&gt;
H.definekey('key');&lt;BR /&gt;
H.definedata('a','b','c');&lt;BR /&gt;
H.definedone();&lt;BR /&gt;
Call missing (key,a,b,c);&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
rc=H.OUTPUT(dataset:"work.out");&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data =work.out;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Any help on this is appreciated.&lt;BR /&gt;
Thanks,&lt;BR /&gt;
SAPPER</description>
      <pubDate>Thu, 11 Feb 2010 15:33:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HASH-object-key-replacement/m-p/55665#M11848</guid>
      <dc:creator>SAPPER</dc:creator>
      <dc:date>2010-02-11T15:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: HASH object key replacement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HASH-object-key-replacement/m-p/55666#M11849</link>
      <description>Are we talking about a SAS 9.2 installation?&lt;BR /&gt;
&lt;BR /&gt;
Because this feature is not available prior that version.&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Thu, 11 Feb 2010 16:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HASH-object-key-replacement/m-p/55666#M11849</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2010-02-11T16:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: HASH object key replacement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HASH-object-key-replacement/m-p/55667#M11850</link>
      <description>Hi Daniel,&lt;BR /&gt;
thanks for the reply.&lt;BR /&gt;
I am running this on 9.1.3.&lt;BR /&gt;
Guess that explains the problem&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
SAPPER.</description>
      <pubDate>Thu, 11 Feb 2010 16:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HASH-object-key-replacement/m-p/55667#M11850</guid>
      <dc:creator>SAPPER</dc:creator>
      <dc:date>2010-02-11T16:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: HASH object key replacement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HASH-object-key-replacement/m-p/55668#M11851</link>
      <description>Even though the duplicate: initialization option isn't available in SAS 9.1.3, you can load the hash object with the last obs from a group of duplicate keys.  To do this, use the REPLACE method.  Here is a small program:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data a;&lt;BR /&gt;
input key a b c;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 10 100 9&lt;BR /&gt;
1 20 200 8&lt;BR /&gt;
2 20 100 8&lt;BR /&gt;
3 30 100 9&lt;BR /&gt;
4 40 100 9&lt;BR /&gt;
4 20 200 8&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  if _N_ = 1 then do;&lt;BR /&gt;
    declare hash H(ordered:'d');&lt;BR /&gt;
    H.definekey('key');&lt;BR /&gt;
    H.definedata('a','b','c');&lt;BR /&gt;
    H.definedone();&lt;BR /&gt;
&lt;BR /&gt;
    /* Load the hash object, getting last obs when there */&lt;BR /&gt;
    /*  are duplicate keys.                              */&lt;BR /&gt;
    do while (^done);&lt;BR /&gt;
      set a end=done;&lt;BR /&gt;
      H.replace();&lt;BR /&gt;
    end;&lt;BR /&gt;
  end;&lt;BR /&gt;
&lt;BR /&gt;
  rc=H.output(dataset:"work.out");&lt;BR /&gt;
&lt;BR /&gt;
  stop;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data =work.out;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 15 Feb 2010 14:39:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HASH-object-key-replacement/m-p/55668#M11851</guid>
      <dc:creator>JasonS_SAS</dc:creator>
      <dc:date>2010-02-15T14:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: HASH object key replacement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HASH-object-key-replacement/m-p/55669#M11852</link>
      <description>Thanks Jason.</description>
      <pubDate>Mon, 15 Feb 2010 14:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HASH-object-key-replacement/m-p/55669#M11852</guid>
      <dc:creator>SAPPER</dc:creator>
      <dc:date>2010-02-15T14:43:20Z</dc:date>
    </item>
  </channel>
</rss>

