<?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: how to get this hash table work? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9867#M2974</link>
    <description>It's difficult to fully understand what you want to accomplish "in words" rather than just showing OUTPUT data - for example, what happened to id1 value 6?&lt;BR /&gt;
&lt;BR /&gt;
Also, paste your SAS-generated logs and suggest you use some diagnostic SAS commands, like:&lt;BR /&gt;
&lt;BR /&gt;
PUTLOG _ALL_;&lt;BR /&gt;
&lt;BR /&gt;
in your program for self-diagnosis and desk-checking.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Fri, 30 Oct 2009 13:43:17 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-10-30T13:43:17Z</dc:date>
    <item>
      <title>how to get this hash table work?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9866#M2973</link>
      <description>I have dataset d1 sorted by id1 and x.&lt;BR /&gt;
&lt;BR /&gt;
data d1;&lt;BR /&gt;
input id1 id2 x;&lt;BR /&gt;
cards;&lt;BR /&gt;
1       2       10&lt;BR /&gt;
1       3        8&lt;BR /&gt;
1       5        7&lt;BR /&gt;
1       1       6&lt;BR /&gt;
2       2       10&lt;BR /&gt;
2       8       5&lt;BR /&gt;
2       20      4&lt;BR /&gt;
3       8976     50&lt;BR /&gt;
3       4       48&lt;BR /&gt;
4       4        48&lt;BR /&gt;
4       982       48&lt;BR /&gt;
5       4           48&lt;BR /&gt;
5     982        48&lt;BR /&gt;
6      4           48&lt;BR /&gt;
6     2           10&lt;BR /&gt;
7     4           48&lt;BR /&gt;
7     2           10&lt;BR /&gt;
7     8            5&lt;BR /&gt;
7     47           4&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I want to get a new data d2 which is a sunset of d1&lt;BR /&gt;
id1    id2     x&lt;BR /&gt;
1       2       10&lt;BR /&gt;
2       8       5&lt;BR /&gt;
3       8976     50&lt;BR /&gt;
4       4        48&lt;BR /&gt;
5     982        48&lt;BR /&gt;
7     47           4&lt;BR /&gt;
&lt;BR /&gt;
I tried this code with hash table. but it does not work.&lt;BR /&gt;
&lt;BR /&gt;
data d2;&lt;BR /&gt;
retain id;&lt;BR /&gt;
declare hash h();&lt;BR /&gt;
rc=h.definekey('id2');&lt;BR /&gt;
rc=h.definedata('x');&lt;BR /&gt;
rc=h.definedone();&lt;BR /&gt;
set d1;&lt;BR /&gt;
rr=h.find(key:id2);&lt;BR /&gt;
if (id1 ne id  and  rr ne 0) then do;&lt;BR /&gt;
    id=id1;&lt;BR /&gt;
    h.add(key:id2, data:x);&lt;BR /&gt;
&lt;BR /&gt;
output;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
How can I fix this problem?&lt;BR /&gt;
Thanks.&lt;BR /&gt;
Jeff</description>
      <pubDate>Fri, 30 Oct 2009 13:14:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9866#M2973</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-30T13:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to get this hash table work?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9867#M2974</link>
      <description>It's difficult to fully understand what you want to accomplish "in words" rather than just showing OUTPUT data - for example, what happened to id1 value 6?&lt;BR /&gt;
&lt;BR /&gt;
Also, paste your SAS-generated logs and suggest you use some diagnostic SAS commands, like:&lt;BR /&gt;
&lt;BR /&gt;
PUTLOG _ALL_;&lt;BR /&gt;
&lt;BR /&gt;
in your program for self-diagnosis and desk-checking.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 30 Oct 2009 13:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9867#M2974</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-10-30T13:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to get this hash table work?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9868#M2975</link>
      <description>Jeff &lt;BR /&gt;
&lt;BR /&gt;
It seems for me that you are asking something without explaning any rules&lt;BR /&gt;
&lt;A href="http://en.wikipedia.org/wiki/Sunset" target="_blank"&gt;http://en.wikipedia.org/wiki/Sunset&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
secondly : why hashing?&lt;BR /&gt;
&lt;BR /&gt;
Andre</description>
      <pubDate>Fri, 30 Oct 2009 13:44:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9868#M2975</guid>
      <dc:creator>Andre</dc:creator>
      <dc:date>2009-10-30T13:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to get this hash table work?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9869#M2976</link>
      <description>here is the rule:&lt;BR /&gt;
i want to get the first largest possible x for each id1 while id2 in d2 can not have duplicates.&lt;BR /&gt;
&lt;BR /&gt;
I want to get a new data d2 which is a sunset of d1&lt;BR /&gt;
id1 id2 x&lt;BR /&gt;
1 2 10    * first record*;&lt;BR /&gt;
2 8 5     * 2       2       10 can not be in d2 because id2=2 already in d2*&lt;BR /&gt;
3 8976 50&lt;BR /&gt;
4 4 48&lt;BR /&gt;
5 982 48   *5       4           48 is not in d2 becuase id=t already in d2. and id1=6 has no   obs in d2 because id2=4, 2 already in d2.&lt;BR /&gt;
7 47 4&lt;BR /&gt;
&lt;BR /&gt;
Thanks.&lt;BR /&gt;
Jeff</description>
      <pubDate>Fri, 30 Oct 2009 14:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9869#M2976</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-30T14:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to get this hash table work?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9870#M2977</link>
      <description>I don't see any up-front SAS code that loads your hash table.&lt;BR /&gt;
&lt;BR /&gt;
Suggest you back away from using hash tables and get your logic working using either a _temporary_ array or a SAS PROC FORMAT approach.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 30 Oct 2009 17:05:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9870#M2977</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-10-30T17:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to get this hash table work?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9871#M2978</link>
      <description>I found the solution which generated the result i want&lt;BR /&gt;
Thanks.&lt;BR /&gt;
Jeff&lt;BR /&gt;
&lt;BR /&gt;
data d2;&lt;BR /&gt;
retain id;&lt;BR /&gt;
id=0;&lt;BR /&gt;
declare hash h();&lt;BR /&gt;
rc=h.definekey('id2');&lt;BR /&gt;
rc=h.definedata('x');&lt;BR /&gt;
rc=h.definedone();&lt;BR /&gt;
do until (eof);&lt;BR /&gt;
    set d1 end=eof;&lt;BR /&gt;
	if (id ne id1) then do;&lt;BR /&gt;
       rc1=h.add();&lt;BR /&gt;
	   if rc1=0  then do;&lt;BR /&gt;
      	 id=id1;&lt;BR /&gt;
       	 output;&lt;BR /&gt;
	   end;&lt;BR /&gt;
	end;&lt;BR /&gt;
 end;&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 30 Oct 2009 19:34:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/how-to-get-this-hash-table-work/m-p/9871#M2978</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-30T19:34:10Z</dc:date>
    </item>
  </channel>
</rss>

