<?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: Join Datasets using Hash Object in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/540104#M148944</link>
    <description>&lt;P&gt;That was one of the issue with Code.&amp;nbsp; But, hey In my defense it was Friday evening : )&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I fixed it and got other errors that I was able to resolve but it was still slow.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I found the code&amp;nbsp;&lt;SPAN&gt;novinosrin provided was better, in that it is simple for someone like me to understand and modify it for re-use.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for your help.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2019 17:07:14 GMT</pubDate>
    <dc:creator>VarunD</dc:creator>
    <dc:date>2019-03-04T17:07:14Z</dc:date>
    <item>
      <title>Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539763#M148781</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use Hash Object to create a dataset Want.&lt;/P&gt;&lt;P&gt;I want to be able to join datasets work.Small and SAS.BIG on ID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Getting an error at Code Line&lt;/P&gt;&lt;P&gt;do unitil (eof);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* Error Message : Expecting an =. */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need help in identifying what is wrong with the code.&lt;/P&gt;&lt;P&gt;I am sorry but the database is quite big and I won't be able to provide details using INFILE option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same do until code works in first step but it doesn't work when I use dataset from SAS library in second do until step.&lt;/P&gt;&lt;P&gt;Is it possible to identify the error with no data information ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code I am using:&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 Want;&lt;/P&gt;&lt;P&gt;declare hash Sub(hashexp:7);&lt;BR /&gt;Sub.definekey('ID');&lt;BR /&gt;Sub.definedata('n');&lt;BR /&gt;Sub.definedone();&lt;/P&gt;&lt;P&gt;do until (eof_Small);&lt;BR /&gt;set Small end=eof_Small&lt;BR /&gt;n+1;&lt;BR /&gt;Sub.add();&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do unitl (eof);&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; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/*Getting an error here that : Expecting an =. */&lt;BR /&gt;set SAS.BIG end=eof ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if Sub.find()=0 then do;&lt;BR /&gt;set Small point=n;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;stop;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 20:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539763#M148781</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-03-01T20:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539764#M148782</link>
      <description>&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194984"&gt;@VarunD&lt;/a&gt;&amp;nbsp; &amp;nbsp;Can you please make it easy for us, hmm rather me to attempt to help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. You could make a small mock sample data in an excel with like 10 rows&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp;You could make a big mock sample data in an excel with like 15 rows&lt;/P&gt;
&lt;P&gt;3. Explain what you want to accomplish by joining i.e your expected output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paste your sample here. That's all you need to do here. Plz&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically post your BIG, SMALL &amp;amp; RESULT samples with an explanation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194984"&gt;@VarunD&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am sorry but the &lt;STRONG&gt;database is quite big&lt;/STRONG&gt; and I won't be able to provide details using INFILE option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 20:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539764#M148782</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-01T20:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539765#M148783</link>
      <description>Will do.. Please allow me few minutes to put it together. Thanks.</description>
      <pubDate>Fri, 01 Mar 2019 20:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539765#M148783</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-03-01T20:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539768#M148786</link>
      <description>&lt;P&gt;Please find the spreadsheet with mock data.&lt;/P&gt;&lt;P&gt;Sorry about not posting it earlier as I was thinking this has something to do with the syntax since I am using hash object for the first time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I simply want to match merge both the datasets on ID.&lt;/P&gt;&lt;P&gt;I tried using PROC SQL and left join to merge small and big but I was having performance issues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I want all the data from small and only matching observations from BIG on ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that information helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for looking into this.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 20:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539768#M148786</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-03-01T20:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539769#M148787</link>
      <description>&lt;P&gt;Thanks. So do you want to fetch the records associated with matching ids in small from big, only matches? or in other words what vars do you want to pull. I can't see the expected output to make out what you want to accomplish&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 21:00:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539769#M148787</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-01T21:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539771#M148788</link>
      <description>&lt;P&gt;Sorry about that.&lt;/P&gt;&lt;P&gt;Yes, all observations from Small and only matches from BIG.&lt;BR /&gt;I want Source New_ID ID and Product from Small and&lt;BR /&gt;Quarter First_Name Last_Name Gender and Age from BIG.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 21:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539771#M148788</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-03-01T21:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539773#M148789</link>
      <description>Maybe we should rule out the obvious first.  Do you really have&lt;BR /&gt;&lt;BR /&gt;do unitl&lt;BR /&gt;&lt;BR /&gt;instead of &lt;BR /&gt;&lt;BR /&gt;do until</description>
      <pubDate>Fri, 01 Mar 2019 21:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539773#M148789</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-01T21:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539774#M148790</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data small;
input (Source	New_ID	ID	Product	Make	fou4th) (:$10.)	(Begin_Date	End_Date) (:yymmdd10.)	In1	In2;
format Begin_Date	End_Date yymmdd10.;
cards;
DB1	123	23456	Car	Honda	Y	20170101	20171115	6	6
DB1	124	23457	Car	Toyota	N	20161101	20171115	11	11
DB1	124	23458	Car	Acura	N	20170101	20171115	7	7
DB1	125	23459	Truck	Lexus	N	20170101	20171115	5	5
DB1	125	23460	Jeep	Jeep	N	20170101	20171115	6	6
DB1	126	23461	Car	Honda	N	20170401	20171115	6	6
DB1	126	23462	Car	Toyota	N	20170101	20171115	2	2
DB1	127	23463	Truck	Acura	N	20170501	20171115	12	12
DB1	127	23464	Jeep	Lexus	N	20170501	20171115	12	12
DB1	128	23465	Car	Jeep	N	20160801	20171115	1	1
;

data big;
input ID $	Quarter	(BGN_DT	END_DT) (:date9.)	(First_Name	Last_Name	MEME_SFX	Gender	Age	Category 	Cat1	Cat2	Cat3	Cat4	Cat5	Cat6	Cat7	Cat8) (:$15.);
format BGN_DT	END_DT date9.;
cards;
23456	1	1-Dec-17	30-Nov-18	Ross	Geller	4	F	19	Female,19-20	A	A	A	A	A	0	0	12
23457	1	1-Dec-17	30-Nov-18	Monica	Geller	1	F	49	Female,50-54	A	A	A	A	A	0	0	11
23458	0	1-Feb-18	31-Jan-19	Chandler	Bing	0	M	49	Male,50-54	A	A	A	A	A	0	0	2
23459	1	1-Dec-17	30-Nov-18	Phoebe	Buffay	0	F	43	Female,40-44	A	A	A	A	A	0	0	1
23460	1	1-Dec-17	30-Nov-18	Joe	Tribianni	1	M	57	Male,55-59	A	A	A	A	A	0	0	12
23461	1	1-Dec-17	30-Nov-18	Pam	Beesly	1	M	37	Male,35-39	A	A	A	A	A	0	0	12
23462	2	1-Dec-16	30-Nov-17	Jim	Helpert	0	M	40	Male,40-44	A	A	A	A	A	0	0	12
23463	1	1-Dec-17	30-Nov-18	Michael	Scott	0	F	62	Female,60-64	A	A	A	A	A	0	0	12
23464	1	1-Dec-17	30-Nov-18	Dwight	Schrute	0	F	22	Female,21-24	A	A	A	A	A	0	0	1
23465	2	1-Dec-16	30-Nov-17	Creed	Braxton	3	M	54	Male,55-59	A	A	A	A	A	0	0	12
;

data want ;
if _n_=1 then do;
if 0 then set small;
   dcl hash H (dataset:'small',multidata:'y') ;
   h.definekey  ("id") ;
   h.definedata ("source", "new_id", "product") ;
   h.definedone () ;
   end;
set big;
/*assuming you want only the matches aka inner join*/
if h.find()=0;
keep Quarter First_Name Last_Name Gender  Age Source New_ID ID  Product;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;you can add use keep=dataset option to process only the wanted vars in the PDV&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set big(keep=Quarter First_Name Last_Name Gender age);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 21:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/539774#M148790</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-01T21:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/540104#M148944</link>
      <description>&lt;P&gt;That was one of the issue with Code.&amp;nbsp; But, hey In my defense it was Friday evening : )&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I fixed it and got other errors that I was able to resolve but it was still slow.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I found the code&amp;nbsp;&lt;SPAN&gt;novinosrin provided was better, in that it is simple for someone like me to understand and modify it for re-use.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for your help.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 17:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/540104#M148944</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-03-04T17:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/540105#M148945</link>
      <description>Thanks a lot for your help.&lt;BR /&gt;Just one quick clarification about the use of multidata:'y' in the code. Is that to allow duplicate values for all variables ?</description>
      <pubDate>Mon, 04 Mar 2019 17:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/540105#M148945</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-03-04T17:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/540111#M148946</link>
      <description>&lt;P&gt;Yes, I was silly to add that as your id's are unique. Good catch mate! My apologies&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I copy pasted syntax from online search and forgot to remove that piece from the syntax. Sincere apologies again!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 17:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/540111#M148946</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-04T17:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: Join Datasets using Hash Object</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/540158#M148960</link>
      <description>No need to apologize.&lt;BR /&gt;If there was Marvel superhero with SAS powers, you would be my hero in that movie.</description>
      <pubDate>Mon, 04 Mar 2019 19:05:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Join-Datasets-using-Hash-Object/m-p/540158#M148960</guid>
      <dc:creator>VarunD</dc:creator>
      <dc:date>2019-03-04T19:05:42Z</dc:date>
    </item>
  </channel>
</rss>

