<?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: Need a Hash Code Check in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Need-a-Hash-Code-Check/m-p/94906#M26842</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alisa,&lt;/P&gt;&lt;P&gt;I am not sure about the purpose of your code, the only hint came from the data set name 'hash_sort', so I will just assume that you want your new table sorted by 'name'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let 's just use Ksharp's approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _N_=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if 0 then set temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; declare hash hs(dataset&lt;STRONG&gt;:'temp'&lt;/STRONG&gt;, ordered:'a', &lt;STRONG&gt;multidata:'y'&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp; hs.definekey('Name');&lt;/P&gt;&lt;P&gt;&amp;nbsp; hs.definedata(all:'y');&lt;/P&gt;&lt;P&gt;&amp;nbsp; hs.definedone();&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;hs.output(dataset:'hash_sort');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: 1. The dataset name 'temp' in the hash definition needs to be quoted. 2. Since key 'name' is not unique index, multidata option needs to be specified. 3. You could defined a hiter to read in the records one by one, but again, it would not be recommended. 4. since you already have 'if 0 then set', so you would not need call missing() and length statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Apr 2012 01:37:27 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-04-26T01:37:27Z</dc:date>
    <item>
      <title>Need a Hash Code Check</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-a-Hash-Code-Check/m-p/94904#M26840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I was wondering if someone could check my code for me.&lt;/P&gt;&lt;P&gt; This is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do I=1 to 1000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do J=1 to 1000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do Name='Mary','Sue','Bob','Ted';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data hash_sort (keep=Name I J);&lt;/P&gt;&lt;P&gt;length Name $4 I 8. J 8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _N_=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if 0 then set temp (keep=Name I J);&lt;/P&gt;&lt;P&gt;&amp;nbsp; declare hash hs(dataset:temp, ordered:'a');&lt;/P&gt;&lt;P&gt;&amp;nbsp; hs.definekey('Name');&lt;/P&gt;&lt;P&gt;&amp;nbsp; hs.definedata('Name','I','J');&lt;/P&gt;&lt;P&gt;&amp;nbsp; hs.definedone();&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing(Name);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My log keeps saying:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: Type mismatch for method parameter 1 at line 743 column 18.&lt;/P&gt;&lt;P&gt;ERROR: Expecting Character type.&lt;/P&gt;&lt;P&gt;ERROR: DATA STEP Component Object failure.&amp;nbsp; Aborted during the EXECUTION phase.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could someone let me know where I am going wrong with my code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alisa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2012 00:59:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-a-Hash-Code-Check/m-p/94904#M26840</guid>
      <dc:creator>InfoAlisaA</dc:creator>
      <dc:date>2012-04-26T00:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need a Hash Code Check</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-a-Hash-Code-Check/m-p/94905#M26841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You forgot to set the quotes around the table name&lt;/P&gt;&lt;P&gt;declare hash hs(dataset:&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/SPAN&gt;temp&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/SPAN&gt;, ordered:'a');&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2012 01:31:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-a-Hash-Code-Check/m-p/94905#M26841</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-04-26T01:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need a Hash Code Check</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-a-Hash-Code-Check/m-p/94906#M26842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alisa,&lt;/P&gt;&lt;P&gt;I am not sure about the purpose of your code, the only hint came from the data set name 'hash_sort', so I will just assume that you want your new table sorted by 'name'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let 's just use Ksharp's approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _N_=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if 0 then set temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; declare hash hs(dataset&lt;STRONG&gt;:'temp'&lt;/STRONG&gt;, ordered:'a', &lt;STRONG&gt;multidata:'y'&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp; hs.definekey('Name');&lt;/P&gt;&lt;P&gt;&amp;nbsp; hs.definedata(all:'y');&lt;/P&gt;&lt;P&gt;&amp;nbsp; hs.definedone();&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;hs.output(dataset:'hash_sort');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: 1. The dataset name 'temp' in the hash definition needs to be quoted. 2. Since key 'name' is not unique index, multidata option needs to be specified. 3. You could defined a hiter to read in the records one by one, but again, it would not be recommended. 4. since you already have 'if 0 then set', so you would not need call missing() and length statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2012 01:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-a-Hash-Code-Check/m-p/94906#M26842</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-04-26T01:37:27Z</dc:date>
    </item>
  </channel>
</rss>

