<?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: Does coalesce statement create multiple records while comparing datasets? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879401#M39029</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Does coalesce statement create multiple records while comparing datasets?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391779"&gt;@Sandeep77&lt;/a&gt;, the first thing you should do is check the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p1vjttz6nuankzn1gh4z3wgcu0bf.htm" target="_self"&gt;documentation&lt;/A&gt; for COALESCE. The answer to your question is the first sentence in the documentation: "Returns the first nonmissing value from a list of numeric arguments".&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jun 2023 16:43:35 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-06-06T16:43:35Z</dc:date>
    <item>
      <title>Does coalesce statement create multiple records while comparing datasets?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879342#M39021</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am comparing two datasets using coalesce but in the output result, I see multiple records with same debt_code. I want to check if the name and surname columns of accounts in Test2 matches with the name in Test1 table. If it matches then flag it as Yes otherwise No. Here is a sample dataset. The code runs successfully but gives multiple records of the same debt_code. Can you please help?&lt;/P&gt;
&lt;P&gt;Data Test_1; &lt;BR /&gt;infile cards expandtabs; &lt;BR /&gt;input icustomerid debt_code rep_code $ Name $ Surname $;&lt;BR /&gt;datalines ; &lt;BR /&gt;79968 379556913 131 Paul Kirby&lt;BR /&gt;98020 335544664 131 Helen Woods&lt;BR /&gt;123015 363876681 131 Steven Crone&lt;BR /&gt;; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;Data Test_2; &lt;BR /&gt;infile cards expandtabs; &lt;BR /&gt;input icustomerid debt_code rep_code $ Name $ Surname $;&lt;BR /&gt;datalines ; &lt;BR /&gt;79968 279618771 005H Pauls Kirby&lt;BR /&gt;79968 328710207 899 Paul Kirby&lt;BR /&gt;79968 334155405 899 Paul Kirby&lt;BR /&gt;79968 340181650 899 Paul Kirby&lt;BR /&gt;79968 347829640 899 Paul Kirby&lt;BR /&gt;98020 233107515 005H Helen Woods&lt;BR /&gt;98020 187724349 005H Helen Wood&lt;BR /&gt;123015 188273239 005H SteveA Crone&lt;BR /&gt;123015 166978189 005H Steven Crone&lt;BR /&gt;123015 174441956 005H Steven Crone&lt;BR /&gt;; &lt;BR /&gt;run;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Comparing_Names as 
select coalesce(a.icustomerid,b.icustomerid) as icustomerid
     , a.debt_code
     , a.rep_code as rep_code1
     , a.dr_inits as first_name1
     , a.dr_name  as last_name1
     , b.debt_code
     , b.rep_code as rep_code2
     , b.dr_inits as first_name2
     , b.dr_name as last_name2
     , case when (a.dr_name=b.dr_name and a.dr_inits=b.dr_inits) then 'YES' else 'NO' end as Match
from Test1 a
full join Test2 b
   on a.icustomerid=b.icustomerid
  and a.dr_name=b.dr_name
  and a.dr_inits=b.dr_inits
order by 1,2
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jun 2023 14:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879342#M39021</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-06-06T14:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Does coalesce statement create multiple records while comparing datasets?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879357#M39022</link>
      <description>&lt;P&gt;Coalesce has nothing to do with creating multiple records.&lt;/P&gt;
&lt;P&gt;Your SQL join does that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually this is a waste of clock cycles&lt;/P&gt;
&lt;PRE&gt; coalesce(a.icustomerid,b.icustomerid) as icustomerid&lt;/PRE&gt;
&lt;P&gt;combined with&lt;/P&gt;
&lt;PRE&gt;full join Test2 b
   on a.icustomerid=b.icustomerid&lt;/PRE&gt;
&lt;P&gt;Your Join has limited the data to where the two values are the same. So the Coalesce will always returm a.icustomerid as icostomerid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Provide an example of what you want the output to look like.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 14:35:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879357#M39022</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-06T14:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Does coalesce statement create multiple records while comparing datasets?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879360#M39023</link>
      <description>&lt;P&gt;The Test_2 table should compare the name and surname with Test_1 and give the output yes if the name and surname is same. Here is a sample dataset for output based on Test_1 and Test_2:&lt;/P&gt;
&lt;P&gt;Data Output; &lt;BR /&gt;infile cards expandtabs; &lt;BR /&gt;input icustomerid debt_code rep_code $ Name $ Surname $ Match $;&lt;BR /&gt;datalines ; &lt;BR /&gt;79968 279618771 005H Pauls Kirby No&lt;BR /&gt;79968 328710207 899 Paul Kirby Yes&lt;BR /&gt;79968 334155405 899 Paul Kirby Yes&lt;BR /&gt;79968 340181650 899 Paul Kirby Yes&lt;BR /&gt;79968 347829640 899 Paul Kirby Yes&lt;BR /&gt;98020 233107515 005H Helen Woods Yes&lt;BR /&gt;98020 187724349 005H Helen Wood No&lt;BR /&gt;123015 188273239 005H SteveA Crone No&lt;BR /&gt;123015 166978189 005H Steven Crone Yes&lt;BR /&gt;123015 174441956 005H Steven Crone Yes&lt;BR /&gt;; &lt;BR /&gt;run; &lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 14:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879360#M39023</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-06-06T14:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Does coalesce statement create multiple records while comparing datasets?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879363#M39024</link>
      <description>&lt;P&gt;It's not a waste of clock cycles for a full join. If a.icustomerid is missing, then coalesce chooses the value of b.customerid.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 14:45:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879363#M39024</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-06T14:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Does coalesce statement create multiple records while comparing datasets?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879365#M39025</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391779"&gt;@Sandeep77&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am comparing two datasets using coalesce but in the output result, I see multiple records with same debt_code. I want to check if the name and surname columns of accounts in Test2 matches with the name in Test1 table. If it matches then flag it as Yes otherwise No. Here is a sample dataset. The code runs successfully but gives multiple records of the same debt_code. Can you please help?&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The fact that you are getting extra records was already explained in &lt;A href="https://communities.sas.com/t5/SAS-Programming/Finding-common-value-from-two-datasets/m-p/879250#M347365" target="_self"&gt;your previous&lt;/A&gt; thread by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 14:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879365#M39025</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-06T14:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Does coalesce statement create multiple records while comparing datasets?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879369#M39026</link>
      <description>&lt;P&gt;Hi, Can you help how can I get the output result as shown previously (Data output). Here I want only the records from Test_2 table and an extra column named match which can show if the name and surname are same as Test_1 dataset.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 14:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879369#M39026</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-06-06T14:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Does coalesce statement create multiple records while comparing datasets?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879392#M39027</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391779"&gt;@Sandeep77&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, Can you help how can I get the output result as shown previously (Data output). Here I want only the records from Test_2 table and an extra column named match which can show if the name and surname are same as Test_1 dataset.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So instead of a FULL join use a LEFT or RIGHT join&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 15:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879392#M39027</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-06T15:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Does coalesce statement create multiple records while comparing datasets?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879401#M39029</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Does coalesce statement create multiple records while comparing datasets?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391779"&gt;@Sandeep77&lt;/a&gt;, the first thing you should do is check the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p1vjttz6nuankzn1gh4z3wgcu0bf.htm" target="_self"&gt;documentation&lt;/A&gt; for COALESCE. The answer to your question is the first sentence in the documentation: "Returns the first nonmissing value from a list of numeric arguments".&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 16:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Does-coalesce-statement-create-multiple-records-while-comparing/m-p/879401#M39029</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-06T16:43:35Z</dc:date>
    </item>
  </channel>
</rss>

