<?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: Using Hash Object to Create and Process Duplicate Records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/591940#M169666</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/252152"&gt;@theponcer&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;OPEN=DEFER, Roger DeAngelis, Richard DeVenezia, and SAS-L in general are your friends:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://listserv.uga.edu/cgi-bin/wa?A2=SAS-L;dadc0d11.1909d" target="_blank"&gt;https://listserv.uga.edu/cgi-bin/wa?A2=SAS-L;dadc0d11.1909d&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Sep 2019 18:09:20 GMT</pubDate>
    <dc:creator>hashman</dc:creator>
    <dc:date>2019-09-26T18:09:20Z</dc:date>
    <item>
      <title>Using Hash Object to Create and Process Duplicate Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/591697#M169553</link>
      <description>&lt;P&gt;I am trying to use a hash table to create a table, output it, and then set it back inside the data table and continue processing. However, the set statement executes at compilation, and the hash code executes at run time. This means I am trying to set a table that doesn't yet exist. Is there a way around this, or am I stuck? Here is my example code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data person;
   input name $ dept $ salary 8.;
   datalines;
John Sales 100000
Mary Acctng 100000
Teresa Sales 100000
;

data dept;
   input dept $;
   datalines;
Sales 
;

data test;
set person;

if 0 then set dept;

if _n_=1 then do;

dcl hash id(dataset:'dept');
id.definekey('dept');
id.definedata('dept');
id.definedone();

dcl hash clones();
clones.definekey('name','dept','salary');
clones.definedata('name','dept','salary');
clones.definedone();

end;

rc_id=id.find();

if rc_id = 0 then 
clones.add();

clones.output(dataset:'work.clones');
/*set work.clones;*/
if name = "Teresa" then salary = salary +10000;
run;

data want_test;
   input name $ dept $ salary 8.;
   datalines;
John Sales 100000
Mary Acctng 100000
Teresa Sales 100000
John Sales 100000
Teresa Sales 110000
;

data want_clones;
   input name $ dept $ salary 8.;
   datalines;
John Sales 100000
Teresa Sales 100000
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 20:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/591697#M169553</guid>
      <dc:creator>theponcer</dc:creator>
      <dc:date>2019-09-25T20:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using Hash Object to Create and Process Duplicate Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/591705#M169561</link>
      <description>&lt;P&gt;Plus the hash output method writes the whole hash table to a SAS table and though should only be called once.&lt;/P&gt;
&lt;P&gt;So yes, you've got it already: What you're trying to do here can't work. But why would you need such a Set statement in first place? You've got already the hash table so just retrieve from there whatever you need. I haven't really understood what you're trying to achieve so can't be more concrete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Correction:&lt;/P&gt;
&lt;P&gt;Using open=defer in the set statement you can write to a hash table and read it with a set statement within the same data step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See discussion below.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 23:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/591705#M169561</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-09-26T23:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using Hash Object to Create and Process Duplicate Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/591855#M169635</link>
      <description>&lt;P&gt;I'm basically trying to write out certain records to a separate table (thus the hash table), duplicate the records in the data table, and then continue processing them. What I've been able to find about duplicating records is essentially, "use the output statement", but if I do this I can no longer process the records as they have already been written out to the table.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 13:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/591855#M169635</guid>
      <dc:creator>theponcer</dc:creator>
      <dc:date>2019-09-26T13:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using Hash Object to Create and Process Duplicate Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/591940#M169666</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/252152"&gt;@theponcer&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;OPEN=DEFER, Roger DeAngelis, Richard DeVenezia, and SAS-L in general are your friends:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://listserv.uga.edu/cgi-bin/wa?A2=SAS-L;dadc0d11.1909d" target="_blank"&gt;https://listserv.uga.edu/cgi-bin/wa?A2=SAS-L;dadc0d11.1909d&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 18:09:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/591940#M169666</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-26T18:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using Hash Object to Create and Process Duplicate Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/592052#M169714</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's wicked! Thanks for sharing.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 23:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/592052#M169714</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-09-26T23:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using Hash Object to Create and Process Duplicate Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/592055#M169715</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Welcome. SAS-L is nowhere near what it used to be volume-wise, but the quality of its elite is still there.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 23:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Hash-Object-to-Create-and-Process-Duplicate-Records/m-p/592055#M169715</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-26T23:32:53Z</dc:date>
    </item>
  </channel>
</rss>

