<?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 Use Selected Key Only in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238052#M43698</link>
    <description>&lt;P&gt;&lt;SPAN&gt;The hash object keeps the multiple values in a list that is associated with the key. This list can be traversed and manipulated by using several methods such as HAS_NEXT or FIND_NEXT.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;See the first example in &lt;A href="https://support.sas.com/resources/papers/sgf2008/better-hashing-sas92.pdf" target="_self"&gt;Better Hashing in SAS® 9.2&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;length key 8 data $ 8;&lt;BR /&gt;if (_n_ = 1) then do;&lt;BR /&gt;declare hash myhash(dataset: "table",multidata&lt;SPAN&gt;: "y"&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;rc = myhash.definekey('key');&lt;BR /&gt;rc = myhash.definedata('data');&lt;BR /&gt;myhash.definedone();&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;do key = '531', '620', '908', '143';&lt;BR /&gt;rc = myhash.find();&lt;BR /&gt;if (rc = 0) then do;&lt;BR /&gt;put key= @15 data=;&lt;BR /&gt;myhash.has_next(result: r);&lt;BR /&gt;do while(r ne 0);&lt;BR /&gt;myhash.find_next();&lt;BR /&gt;put key= @15 data= &amp;nbsp;@25 '(dup)';&lt;BR /&gt;myhash.has_next(result: r);&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Dec 2015 13:53:02 GMT</pubDate>
    <dc:creator>mohamed_zaki</dc:creator>
    <dc:date>2015-12-07T13:53:02Z</dc:date>
    <item>
      <title>Hash Object Use Selected Key Only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238035#M43689</link>
      <description>&lt;P&gt;Good morning.&lt;/P&gt;
&lt;P&gt;In the guide sas (&lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002576871.htm)" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002576871.htm)&lt;/A&gt; is an example of how the option 'replace' stores the last duplicate key record, but it does not show how to record in the object hash values of duplicate key:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table;
  input key data $;
  datalines;
  531 yellow
  620 green
  531 blue
  908 orange
  620 brown
  143 purple
 run;

data _null_;
length key 8 data $ 8;
if (_n_ = 1) then do;
    declare hash myhash(dataset: "table", duplicate: "r");
    rc = myhash.definekey('key');
    rc = myhash.definedata('data');
    myhash.definedone();
 end;

rc = myhash.output(dataset:"otable");
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;I would get in the dataset 'table', the values of duplicate key. It's possible?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 09:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238035#M43689</guid>
      <dc:creator>mariopellegrini</dc:creator>
      <dc:date>2015-12-07T09:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Object Use Selected Key Only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238043#M43691</link>
      <description>&lt;P&gt;Give example of your desired output....&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 11:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238043#M43691</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-12-07T11:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Object Use Selected Key Only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238049#M43695</link>
      <description>&lt;P&gt;a dataset identical to the original one (table), including duplicate data&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 12:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238049#M43695</guid>
      <dc:creator>mariopellegrini</dc:creator>
      <dc:date>2015-12-07T12:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Object Use Selected Key Only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238050#M43696</link>
      <description>&lt;P&gt;Then use the the option&amp;nbsp;&lt;/P&gt;&lt;P&gt;multidata="Y"&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 12:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238050#M43696</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-12-07T12:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Object Use Selected Key Only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238051#M43697</link>
      <description>&lt;P&gt;I've already tried, but I do not get duplicates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table;
  input key data $;
  datalines;
  531 yellow
  620 green
  531 blue
  908 orange
  620 brown
  143 purple
 run;

data _null_;
length key 8 data $ 8;
if (_n_ = 1) then do;
    declare hash myhash(dataset: "table",   multidata = 'Y');
    rc = myhash.definekey('key');
    rc = myhash.definedata('data');
    myhash.definedone();
 end;

rc = myhash.output(dataset:"otable");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Dec 2015 12:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238051#M43697</guid>
      <dc:creator>mariopellegrini</dc:creator>
      <dc:date>2015-12-07T12:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Object Use Selected Key Only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238052#M43698</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The hash object keeps the multiple values in a list that is associated with the key. This list can be traversed and manipulated by using several methods such as HAS_NEXT or FIND_NEXT.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;See the first example in &lt;A href="https://support.sas.com/resources/papers/sgf2008/better-hashing-sas92.pdf" target="_self"&gt;Better Hashing in SAS® 9.2&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;length key 8 data $ 8;&lt;BR /&gt;if (_n_ = 1) then do;&lt;BR /&gt;declare hash myhash(dataset: "table",multidata&lt;SPAN&gt;: "y"&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;rc = myhash.definekey('key');&lt;BR /&gt;rc = myhash.definedata('data');&lt;BR /&gt;myhash.definedone();&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;do key = '531', '620', '908', '143';&lt;BR /&gt;rc = myhash.find();&lt;BR /&gt;if (rc = 0) then do;&lt;BR /&gt;put key= @15 data=;&lt;BR /&gt;myhash.has_next(result: r);&lt;BR /&gt;do while(r ne 0);&lt;BR /&gt;myhash.find_next();&lt;BR /&gt;put key= @15 data= &amp;nbsp;@25 '(dup)';&lt;BR /&gt;myhash.has_next(result: r);&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 13:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238052#M43698</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-12-07T13:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Object Use Selected Key Only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238057#M43702</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;multidata&amp;amp;colon;'Y'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;RTM&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 18:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238057#M43702</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-12-07T18:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Object Use Selected Key Only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238104#M43715</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt; wrote:&lt;BR /&gt;multidata&amp;amp;colon;'Y'&lt;BR /&gt;&lt;BR /&gt;RTM&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Wondering when SAS forum gonna fix this.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 17:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238104#M43715</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-12-07T17:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Object Use Selected Key Only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238129#M43723</link>
      <description>I modified to make it CODE but that didn't fix it. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;</description>
      <pubDate>Mon, 07 Dec 2015 18:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238129#M43723</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-12-07T18:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Object Use Selected Key Only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238130#M43724</link>
      <description>&lt;P&gt;It has been consistent :).&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 18:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238130#M43724</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-12-07T18:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Object Use Selected Key Only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238149#M43726</link>
      <description>&lt;P&gt;This&amp;nbsp;method is intricate, it is perhaps best to add the variable _N_ the key object to not have duplicates?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 19:56:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Object-Use-Selected-Key-Only/m-p/238149#M43726</guid>
      <dc:creator>mariopellegrini</dc:creator>
      <dc:date>2015-12-07T19:56:59Z</dc:date>
    </item>
  </channel>
</rss>

