<?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: Merging using proc sql vs data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752123#M236871</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/385462"&gt;@Baba9&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you checked the log to see if that gives any clues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is anything in the log you need help to understand then please post its contents using the "&amp;lt;/&amp;gt;" icon when posting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Jul 2021 16:52:10 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2021-07-05T16:52:10Z</dc:date>
    <item>
      <title>Merging using proc sql vs data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752119#M236868</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;I would appreciate if someone can advise the difference in the 2 merging techniques below:&lt;/P&gt;&lt;P&gt;I recieve different counts using the data step merge vs the proc sql and i need to understand why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Technique 1&amp;nbsp;

proc sql;
create table NACRSFY19_int_AT as
select distinct *
from NACRSFY19_int as a inner join nacrs19.Anaesthetic_technique as b
on a.am_care_key=b.am_care_key;
quit;
/*5,829,296*/



Technique 2
proc sort data= NACRSFY19_int;
by am_care_key;
run;


proc sort data= nacrs19.Anaesthetic_technique out=AT_sorted;
by am_care_key;
run;
/*16,943,476*/



data nacrs_AT_19;
merge NACRSFY19_int (in=a) AT_sorted (in=b);
by am_care_key;
if a and b;
run;
/*3,237,261*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jul 2021 16:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752119#M236868</guid>
      <dc:creator>Baba9</dc:creator>
      <dc:date>2021-07-05T16:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Merging using proc sql vs data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752123#M236871</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/385462"&gt;@Baba9&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you checked the log to see if that gives any clues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is anything in the log you need help to understand then please post its contents using the "&amp;lt;/&amp;gt;" icon when posting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 16:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752123#M236871</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2021-07-05T16:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Merging using proc sql vs data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752128#M236874</link>
      <description>Is AM_CARE_KEY unique in each data set? I suspect not...</description>
      <pubDate>Mon, 05 Jul 2021 17:05:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752128#M236874</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-05T17:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Merging using proc sql vs data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752129#M236875</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; proc sql;
633   create table NACRSFY19_int_AT as
634   select distinct *
635   from NACRSFY19_int as a inner join nacrs19.Anaesthetic_technique as b
636   on a.am_care_key=b.am_care_key;
WARNING: Variable AM_CARE_KEY already exists on file WORK.NACRSFY19_INT_AT.
NOTE: SAS threaded sort was used.
NOTE: Table WORK.NACRSFY19_INT_AT created, with 5829296 rows and 10 columns.

637   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           5.57 seconds
      user cpu time       4.96 seconds
      system cpu time     2.89 seconds
      memory              968258.75k
      OS Memory           999016.00k
      Timestamp           2021-07-05 12:33:11 PM
      Step Count                        102  Switch Count  0


638   data NACRSFY19_int2 ;
639   merge nacrs_AT_19 (in=a) Excl_combined (in=b);
640   by am_care_key;
641   if a and not b;
642   run;

INFO: The variable CCI_INTERV_CODE on data set WORK.NACRS_AT_19 will be overwritten by data set
      WORK.EXCL_COMBINED.
INFO: The variable INTERV_SEQ_ID on data set WORK.NACRS_AT_19 will be overwritten by data set
      WORK.EXCL_COMBINED.
INFO: The variable STATUS_ATTRIBUTE_CODE on data set WORK.NACRS_AT_19 will be overwritten by data
      set WORK.EXCL_COMBINED.
INFO: The variable INTERV_OOH_IND_CODE on data set WORK.NACRS_AT_19 will be overwritten by data
      set WORK.EXCL_COMBINED.
NOTE: There were 3237261 observations read from the data set WORK.NACRS_AT_19.
NOTE: There were 37200 observations read from the data set WORK.EXCL_COMBINED.
NOTE: The data set WORK.NACRSFY19_INT2 has 3205688 observations and 21 variables.
NOTE: DATA statement used (Total process time):
      real time           1.34 seconds
      user cpu time       0.92 seconds
      system cpu time     0.28 seconds
      memory              1080.90k
      OS Memory           33016.00k
      Timestamp           2021-07-05 12:36:14 PM
      Step Count                        103  Switch Count  0

Hi&amp;nbsp;@ pasted&amp;nbsp;the&amp;nbsp;log&amp;nbsp;&lt;BR /&gt;Thankyou&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jul 2021 17:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752129#M236875</guid>
      <dc:creator>Baba9</dc:creator>
      <dc:date>2021-07-05T17:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Merging using proc sql vs data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752130#M236876</link>
      <description>It’s not unique&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Jul 2021 17:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752130#M236876</guid>
      <dc:creator>Baba9</dc:creator>
      <dc:date>2021-07-05T17:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Merging using proc sql vs data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752131#M236877</link>
      <description>A data step cannot do a many to many merge.&lt;BR /&gt;&lt;A href="https://www.listendata.com/2015/12/sas-many-to-many-merge.html" target="_blank"&gt;https://www.listendata.com/2015/12/sas-many-to-many-merge.html&lt;/A&gt;</description>
      <pubDate>Mon, 05 Jul 2021 17:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752131#M236877</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-05T17:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Merging using proc sql vs data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752153#M236888</link>
      <description>&lt;P&gt;Your log confirms that you are doing a many-to-many merge which SQL can do but a DATA step merge cannot. Refer to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;'s explanation.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 20:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752153#M236888</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-07-05T20:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Merging using proc sql vs data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752158#M236891</link>
      <description>&lt;P&gt;These are two different joins.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;NACRSFY19_int, nacrs19.Anaesthetic_technique&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in the SQL,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;nacrs_AT_19, Excl_combined&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in the data step.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 20:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-using-proc-sql-vs-data-step/m-p/752158#M236891</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-05T20:24:39Z</dc:date>
    </item>
  </channel>
</rss>

