<?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: SAS Hash Object for duplicating rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Object-for-duplicating-rows/m-p/296287#M62020</link>
    <description>Thanks a lot for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Sat, 03 Sep 2016 05:14:39 GMT</pubDate>
    <dc:creator>_SAS_</dc:creator>
    <dc:date>2016-09-03T05:14:39Z</dc:date>
    <item>
      <title>SAS Hash Object for duplicating rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Object-for-duplicating-rows/m-p/296167#M61986</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please consider the example in the code below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
	length 
		key $4
		name $10
		address $20
	;
	input key $ name $ address $;

datalines;
a John Street_123
b Mark Drive_456
c Martin Boulevard_789
run;

data two;
	length 
		key $4
		phone $10
		email $20
	;
	input key $ phone $ email $;

datalines;
a 1234 abc@abc
b 5678 def@def
c 91011 ghi@ghi
a 121314 jkl@jkl
run;

data three;
	length 
		phone $10
		email $20
	;
	set one;

	if _N_=1 then do;
		declare hash h(dataset:"work.two");
		h.definekey("key");
		h.definedata("phone", "email");
		h.definedone();
	end;

	if h.find() eq 0 then do;
			put phone email;
	end;
run;

proc sql;
create table four as
select t1.key, t1.name, t1.address, 
		t2.phone, t2.email
from one t1 inner join two t2 on t1.key = t2.key;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My question - is there a chance to modify the hash object call to generate the same kind of result as for the querry four?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i mean is that the hash table seems to take the first observation where the key matches (just like a vlookup in xls) but it does not perform a cartesian product like the inner join in the proc sql.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to change this behavior?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2016 17:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Object-for-duplicating-rows/m-p/296167#M61986</guid>
      <dc:creator>_SAS_</dc:creator>
      <dc:date>2016-09-02T17:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Hash Object for duplicating rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Object-for-duplicating-rows/m-p/296276#M62014</link>
      <description>&lt;PRE&gt;
Of course, Hash Table can do that .



data one;
	length 
		key $4
		name $10
		address $20
	;
	input key $ name $ address $;

datalines;
a John Street_123
b Mark Drive_456
c Martin Boulevard_789
;
run;

data two;
	length 
		key $4
		phone $10
		email $20
	;
	input key $ phone $ email $;
datalines;
a 1234 abc@abc
b 5678 def@def
c 91011 ghi@ghi
a 121314 jkl@jkl
;
run;

data three;
	if _N_=1 then do;
	 if 0 then set work.two(rename=(phone=p2 email=e2));
		declare hash h(dataset:"work.two(rename=(phone=p2 email=e2))",multidata:'y');
		h.definekey("key");
		h.definedata("p2", "e2");
		h.definedone();
	end;
set one;
rc=h.find();
do while(rc=0);
 output;
 rc=h.find_next();
end;
drop rc;
run;



&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Sep 2016 03:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Object-for-duplicating-rows/m-p/296276#M62014</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-03T03:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Hash Object for duplicating rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Object-for-duplicating-rows/m-p/296287#M62020</link>
      <description>Thanks a lot for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Sat, 03 Sep 2016 05:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Hash-Object-for-duplicating-rows/m-p/296287#M62020</guid>
      <dc:creator>_SAS_</dc:creator>
      <dc:date>2016-09-03T05:14:39Z</dc:date>
    </item>
  </channel>
</rss>

