<?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: Match and merge two datasets in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Match-and-merge-two-datasets/m-p/937416#M42142</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data db2;
set db;
if _n_ = 1
then do;
  length index_2 8;
  declare hash db1 (dataset:"db1");
  db1.definekey("codes");
  db1.definedata("index_2");
  db1.definedone();
end;
if index_1
then rc = db1.find();
else index_2 = 0;
drop rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 29 Jul 2024 08:45:42 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2024-07-29T08:45:42Z</dc:date>
    <item>
      <title>Match and merge two datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Match-and-merge-two-datasets/m-p/937413#M42141</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following two datasets:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID $20. Codes Index_1;
cards;
0001 2134  1
0001 87    0
0002 154   1 
0002 65    0
0003 88    1
0003 34    0
0003 78    0
run;


data DB1;
  input Codes Index_2;
cards;
2134  6
87    4
154   2 
65    6
88    1
34    3
78    5
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is there a way to add Index_2 from DB1 to DB only when Index_1 from DB is&amp;nbsp; = 1 to get the following?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data DB2;
  input ID $20. Codes Index_1 Index_2;
cards;
0001 2134  1    6
0001 87    0    0
0002 154   1    2
0002 65    0    0
0003 88    1    1
0003 34    0    0
0003 78    0    0
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 07:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Match-and-merge-two-datasets/m-p/937413#M42141</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-07-29T07:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Match and merge two datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Match-and-merge-two-datasets/m-p/937416#M42142</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data db2;
set db;
if _n_ = 1
then do;
  length index_2 8;
  declare hash db1 (dataset:"db1");
  db1.definekey("codes");
  db1.definedata("index_2");
  db1.definedone();
end;
if index_1
then rc = db1.find();
else index_2 = 0;
drop rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jul 2024 08:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Match-and-merge-two-datasets/m-p/937416#M42142</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-07-29T08:45:42Z</dc:date>
    </item>
  </channel>
</rss>

