<?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 How to achieve SAS merge in SQL joins in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-achieve-SAS-merge-in-SQL-joins/m-p/785800#M250826</link>
    <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN style="font-family: inherit;"&gt;I am converting SAS code to Spark. In one of the data step SAS is doing merge (many to many). I need to achieve same in Spark. Please help me to get this done.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;CODE&gt;proc sort data=dat1;by mbr_sys_id clm_aud_nbr2;run;
proc sort data=dat2;by mbr_sys_id clm_aud_nbr2;run;

data want;
 merge dat1(in=a)
    dat2(in=b);
    by mbr_sys_id clm_aud_nbr2;
    if a and b;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 853px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66705i6673AA85CDC444CC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;I want to get this same output using proc sql.&amp;nbsp;&lt;/CODE&gt;Can you please help me in here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 13 Dec 2021 17:04:51 GMT</pubDate>
    <dc:creator>yadavdharmendra</dc:creator>
    <dc:date>2021-12-13T17:04:51Z</dc:date>
    <item>
      <title>How to achieve SAS merge in SQL joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-achieve-SAS-merge-in-SQL-joins/m-p/785800#M250826</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN style="font-family: inherit;"&gt;I am converting SAS code to Spark. In one of the data step SAS is doing merge (many to many). I need to achieve same in Spark. Please help me to get this done.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;CODE&gt;proc sort data=dat1;by mbr_sys_id clm_aud_nbr2;run;
proc sort data=dat2;by mbr_sys_id clm_aud_nbr2;run;

data want;
 merge dat1(in=a)
    dat2(in=b);
    by mbr_sys_id clm_aud_nbr2;
    if a and b;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 853px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66705i6673AA85CDC444CC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;I want to get this same output using proc sql.&amp;nbsp;&lt;/CODE&gt;Can you please help me in here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 13 Dec 2021 17:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-achieve-SAS-merge-in-SQL-joins/m-p/785800#M250826</guid>
      <dc:creator>yadavdharmendra</dc:creator>
      <dc:date>2021-12-13T17:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to achieve SAS merge in SQL joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-achieve-SAS-merge-in-SQL-joins/m-p/785814#M250835</link>
      <description>&lt;P&gt;DATA step merges cannot do many-to-many joins.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="xisDoc-noteGenText"&gt;Note: &lt;/SPAN&gt;The MERGE statement does not produce a Cartesian product on a many-to-many match-merge. Instead, it performs a one-to-one merge while there are observations in the BY group in at least one data set. When all observations in the BY group have been read from one data set and there are still more observations in another data set, SAS performs a one-to-many merge until all BY group observations have been read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1i8w2bwu1fn5kn1gpxj18xttbb0.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1i8w2bwu1fn5kn1gpxj18xttbb0.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you're showing is an inner join.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also need to be careful if you share any variable names in the data sets in a MERGE statement. SAS takes the right-most value.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 17:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-achieve-SAS-merge-in-SQL-joins/m-p/785814#M250835</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-12-13T17:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to achieve SAS merge in SQL joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-achieve-SAS-merge-in-SQL-joins/m-p/785852#M250851</link>
      <description>&lt;P&gt;The following SQL will do a many-to-many join which is similar but not the same as a SAS MERGE:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as 
  select *
  from dat1 as A
  inner join dat2 as B
  on A.mbr_sys_id = B.mbr_sys_id
  and A.clm_aud_nbr2 = B.clm_aud_nbr2
  ;
quit;
  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Dec 2021 19:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-achieve-SAS-merge-in-SQL-joins/m-p/785852#M250851</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-12-13T19:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to achieve SAS merge in SQL joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-achieve-SAS-merge-in-SQL-joins/m-p/785971#M250885</link>
      <description>&lt;P&gt;I can do this inner join but how can I achieve same out which sas merge produces .&lt;/P&gt;&lt;P&gt;Actually bigger picture is I am converting SAS code to SPARK 3 I do not have merge in spark&lt;/P&gt;&lt;P&gt;only i have joins, if you can replicate SAS merge output into sql , it will be helpful for me.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 11:39:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-achieve-SAS-merge-in-SQL-joins/m-p/785971#M250885</guid>
      <dc:creator>yadavdharmendra</dc:creator>
      <dc:date>2021-12-14T11:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to achieve SAS merge in SQL joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-achieve-SAS-merge-in-SQL-joins/m-p/785982#M250889</link>
      <description>&lt;P&gt;As already stated, SQL join and data step merge are not the same.&lt;/P&gt;
&lt;P&gt;Under many circumstances they produce the same result.&lt;/P&gt;
&lt;P&gt;But for you to be able to migrate in a consistent way, you need to understand the requirement behind the SAS code, and how your input data behaves,&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 12:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-achieve-SAS-merge-in-SQL-joins/m-p/785982#M250889</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2021-12-14T12:01:21Z</dc:date>
    </item>
  </channel>
</rss>

