<?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 Hash Question! in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Hash-Question/m-p/206367#M51295</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Experts,&lt;/P&gt;&lt;P&gt;When I create a hash table, I have to specify the key value, but if I want to replace the key value with a new variable created during the hash iterator process within the same data step. How do I do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the code below, I want the dataset work.temp1(highlighted in red) to be created&amp;nbsp; before it hold by "mylittlehash1" ,how do I achieve that?&lt;/P&gt;&lt;P&gt;My goal is to use one single datastep (with hash) to complete the task as shown in the code below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data work.temp1 work.temp2;&lt;BR /&gt;attrib filename length=$1000&lt;BR /&gt;sfname length=$1000&lt;BR /&gt;key length=$1000;&lt;/P&gt;&lt;P&gt;if _n_=1 then do;&lt;BR /&gt;declare hash mylittlehash(dataset: 'library.want', ordered:'yes');&lt;BR /&gt;declare hiter mylittlehashter('mylittlehash');&lt;BR /&gt;mylittlehash.defineData('filename');&lt;BR /&gt;mylittlehash.defineKey('sfname');&lt;BR /&gt;mylittlehash.defineDone();&lt;BR /&gt;call missing(filename,sfname,key);&lt;BR /&gt;end;&lt;BR /&gt;rc=mylittlehashter.first();&lt;BR /&gt;do until (rc ne 0);&lt;BR /&gt;perlexpression2=prxparse("/\w*(\w\w\d\d\d\d)(\w)\w*/");&lt;BR /&gt;if prxmatch(perlexpression2,filename) then do;&lt;BR /&gt;Key=upcase((prxposn(perlexpression2,1,filename)));&lt;BR /&gt;output work.temp1;&lt;BR /&gt;rc=mylittlehashter.next();&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;declare hash mylittlehash1(dataset: &lt;SPAN style="color: #ff0000;"&gt;'work.temp1'&lt;/SPAN&gt;, ordered:'yes', duplicate: 'r');&lt;BR /&gt;mylittlehash1.defineKey('key');&lt;BR /&gt;mylittlehash1.defineData('key');&lt;BR /&gt;mylittlehash1.defineDone();&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;set files_found;&lt;BR /&gt; perlexpression=prxparse("/\w*(\w\w\d\d\d\d)(\w)\w*/");&lt;BR /&gt; if prxmatch(perlexpression,filename) then do;&lt;BR /&gt; Key=upcase((prxposn(perlexpression,1,filename)));&lt;BR /&gt; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if prxposn(perlexpression,2,filename)="Z";&lt;BR /&gt; rc=mylittlehash1.check();&lt;BR /&gt;if rc=0 then output work.temp2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Mar 2015 22:42:33 GMT</pubDate>
    <dc:creator>gyambqt</dc:creator>
    <dc:date>2015-03-19T22:42:33Z</dc:date>
    <item>
      <title>Hash Question!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Hash-Question/m-p/206367#M51295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Experts,&lt;/P&gt;&lt;P&gt;When I create a hash table, I have to specify the key value, but if I want to replace the key value with a new variable created during the hash iterator process within the same data step. How do I do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the code below, I want the dataset work.temp1(highlighted in red) to be created&amp;nbsp; before it hold by "mylittlehash1" ,how do I achieve that?&lt;/P&gt;&lt;P&gt;My goal is to use one single datastep (with hash) to complete the task as shown in the code below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data work.temp1 work.temp2;&lt;BR /&gt;attrib filename length=$1000&lt;BR /&gt;sfname length=$1000&lt;BR /&gt;key length=$1000;&lt;/P&gt;&lt;P&gt;if _n_=1 then do;&lt;BR /&gt;declare hash mylittlehash(dataset: 'library.want', ordered:'yes');&lt;BR /&gt;declare hiter mylittlehashter('mylittlehash');&lt;BR /&gt;mylittlehash.defineData('filename');&lt;BR /&gt;mylittlehash.defineKey('sfname');&lt;BR /&gt;mylittlehash.defineDone();&lt;BR /&gt;call missing(filename,sfname,key);&lt;BR /&gt;end;&lt;BR /&gt;rc=mylittlehashter.first();&lt;BR /&gt;do until (rc ne 0);&lt;BR /&gt;perlexpression2=prxparse("/\w*(\w\w\d\d\d\d)(\w)\w*/");&lt;BR /&gt;if prxmatch(perlexpression2,filename) then do;&lt;BR /&gt;Key=upcase((prxposn(perlexpression2,1,filename)));&lt;BR /&gt;output work.temp1;&lt;BR /&gt;rc=mylittlehashter.next();&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;declare hash mylittlehash1(dataset: &lt;SPAN style="color: #ff0000;"&gt;'work.temp1'&lt;/SPAN&gt;, ordered:'yes', duplicate: 'r');&lt;BR /&gt;mylittlehash1.defineKey('key');&lt;BR /&gt;mylittlehash1.defineData('key');&lt;BR /&gt;mylittlehash1.defineDone();&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;set files_found;&lt;BR /&gt; perlexpression=prxparse("/\w*(\w\w\d\d\d\d)(\w)\w*/");&lt;BR /&gt; if prxmatch(perlexpression,filename) then do;&lt;BR /&gt; Key=upcase((prxposn(perlexpression,1,filename)));&lt;BR /&gt; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if prxposn(perlexpression,2,filename)="Z";&lt;BR /&gt; rc=mylittlehash1.check();&lt;BR /&gt;if rc=0 then output work.temp2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Mar 2015 22:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Hash-Question/m-p/206367#M51295</guid>
      <dc:creator>gyambqt</dc:creator>
      <dc:date>2015-03-19T22:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Hash Question!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Hash-Question/m-p/206368#M51296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please post your questions only once into a single forum. My reply given here &lt;A __default_attr="73852" __jive_macro_name="thread" class="jive_macro jive_macro_thread" href="https://communities.sas.com/"&gt;&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Mar 2015 23:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Hash-Question/m-p/206368#M51296</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-03-19T23:45:51Z</dc:date>
    </item>
  </channel>
</rss>

