<?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 Data Lookup Question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hash-Data-Lookup-Question/m-p/12123#M1297</link>
    <description>My experience using the feature, as documented, is that the PDV is not altered (behavior I would definitely want to occur) - you will want to test rc (in your code) to determine how to proceed.  The interpretation of your observation "..then 'nothing' is returned..." is not totally clear to me.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS(R) 9.2 Language Reference: Dictionary - FIND method:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a002588683.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a002588683.htm&lt;/A&gt;</description>
    <pubDate>Fri, 27 Mar 2009 20:44:57 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-03-27T20:44:57Z</dc:date>
    <item>
      <title>Hash Data Lookup Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Data-Lookup-Question/m-p/12122#M1296</link>
      <description>Dear SAS Forum,&lt;BR /&gt;
&lt;BR /&gt;
I'm just starting out with the hash object.  I was under the impression that if the find method cannot find a match then "nothing" is returned in the datavalues.  However it looks like the last value in the PDV is returned if the find method cannot match to the key.  &lt;BR /&gt;
&lt;BR /&gt;
I thought that I could mimic a left join with the hash object.  I could use call missing on grade before the find method?&lt;BR /&gt;
&lt;BR /&gt;
Can someone shed some light?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data grades;&lt;BR /&gt;
input gname $ grade $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
Alfred A&lt;BR /&gt;
Alice B&lt;BR /&gt;
Barbara A&lt;BR /&gt;
Carol D&lt;BR /&gt;
Henry C&lt;BR /&gt;
James B&lt;BR /&gt;
Jane B&lt;BR /&gt;
Janet C&lt;BR /&gt;
Jeffrey A&lt;BR /&gt;
John A&lt;BR /&gt;
Joyce D&lt;BR /&gt;
Judy F&lt;BR /&gt;
Louise A&lt;BR /&gt;
Mary A&lt;BR /&gt;
Philip C&lt;BR /&gt;
Robert C&lt;BR /&gt;
Ronald C&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  create table class1 as&lt;BR /&gt;
   select a.*, b.grade&lt;BR /&gt;
   from SASHELP.CLASS a left join grades b on a.name=b.gname&lt;BR /&gt;
   order by a.name;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
data class2;&lt;BR /&gt;
&lt;BR /&gt;
  if 0 then set grades(obs=1);&lt;BR /&gt;
&lt;BR /&gt;
  if _n_ eq 1 then do;&lt;BR /&gt;
    &lt;BR /&gt;
    declare hash grades(dataset:"grades");&lt;BR /&gt;
	grades.definekey("gname");&lt;BR /&gt;
	grades.definedata("grade");&lt;BR /&gt;
	grades.definedone();&lt;BR /&gt;
&lt;BR /&gt;
  end;&lt;BR /&gt;
&lt;BR /&gt;
  set sashelp.class;&lt;BR /&gt;
&lt;BR /&gt;
  rc=grades.find(key: name);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc compare data=class1 compare=class2;&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 27 Mar 2009 18:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Data-Lookup-Question/m-p/12122#M1296</guid>
      <dc:creator>darrylovia</dc:creator>
      <dc:date>2009-03-27T18:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Data Lookup Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Data-Lookup-Question/m-p/12123#M1297</link>
      <description>My experience using the feature, as documented, is that the PDV is not altered (behavior I would definitely want to occur) - you will want to test rc (in your code) to determine how to proceed.  The interpretation of your observation "..then 'nothing' is returned..." is not totally clear to me.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS(R) 9.2 Language Reference: Dictionary - FIND method:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a002588683.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a002588683.htm&lt;/A&gt;</description>
      <pubDate>Fri, 27 Mar 2009 20:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Data-Lookup-Question/m-p/12123#M1297</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-03-27T20:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Data Lookup Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-Data-Lookup-Question/m-p/12124#M1298</link>
      <description>Ran another experiment.&lt;BR /&gt;
&lt;BR /&gt;
By adding a call missing before the find method, the hash merge gets the same results as a LEFT JOIN.  See the code below.  If the call missing is not present &lt;BR /&gt;
the grade for "William" is the grade for "Ronald". Hmmm&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data grades;&lt;BR /&gt;
input gname $ grade $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
Alfred A&lt;BR /&gt;
Alice B&lt;BR /&gt;
Barbara A&lt;BR /&gt;
Carol D&lt;BR /&gt;
Henry C&lt;BR /&gt;
James B&lt;BR /&gt;
Jane B&lt;BR /&gt;
Janet C&lt;BR /&gt;
Jeffrey A&lt;BR /&gt;
John A&lt;BR /&gt;
Joyce D&lt;BR /&gt;
Judy F&lt;BR /&gt;
Louise A&lt;BR /&gt;
Mary A&lt;BR /&gt;
Philip C&lt;BR /&gt;
Robert C&lt;BR /&gt;
Ronald C&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  create table class1 as&lt;BR /&gt;
   select a.*, b.grade&lt;BR /&gt;
   from SASHELP.CLASS a left join grades b on a.name=b.gname&lt;BR /&gt;
   order by a.name;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
data class2;&lt;BR /&gt;
&lt;BR /&gt;
  if 0 then set grades(obs=1);&lt;BR /&gt;
&lt;BR /&gt;
  if _n_ eq 1 then do;&lt;BR /&gt;
    &lt;BR /&gt;
    declare hash grades(dataset:"grades");&lt;BR /&gt;
	grades.definekey("gname");&lt;BR /&gt;
	grades.definedata("grade");&lt;BR /&gt;
	grades.definedone();&lt;BR /&gt;
&lt;BR /&gt;
  end;&lt;BR /&gt;
&lt;BR /&gt;
  set sashelp.class;&lt;BR /&gt;
  rc=grades.find(key: name);&lt;BR /&gt;
  if rc ne 0 then call missing(grade);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc compare data=class1 compare=class2;&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 27 Mar 2009 20:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-Data-Lookup-Question/m-p/12124#M1298</guid>
      <dc:creator>darrylovia</dc:creator>
      <dc:date>2009-03-27T20:58:35Z</dc:date>
    </item>
  </channel>
</rss>

