<?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: What is the way to use joins instead of merge for below code? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-way-to-use-joins-instead-of-merge-for-below-code/m-p/739208#M230690</link>
    <description>&lt;P&gt;Stay with your data step.&lt;/P&gt;
&lt;P&gt;SQL (untested) might look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    dm.*,
    ae.aeterm,
    cm.cmtrt,
    mh.mhterm
  from dm a
  left join ae
  on dm.usubjid = ae.usubjid
  left join cm
  on dm.usubjid = cm.usubjid
  left join mh
  on dm.usibjid = mh.usubjid
  where a.usubjid in (
    select distinct usubjid from ae
    union
    select distinct usubjid from cm
    union
    select distinct usubjid from mh
  )
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I can only repeat the last line of my previous post. Compare the codes, and you'll see that forcing this unto SQL is just pure idiocy.&lt;/P&gt;</description>
    <pubDate>Wed, 05 May 2021 13:00:57 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-05-05T13:00:57Z</dc:date>
    <item>
      <title>What is the way to use joins instead of merge for below code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-way-to-use-joins-instead-of-merge-for-below-code/m-p/739196#M230681</link>
      <description>&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;merge dm(in=a) ae(in=b) cm(in=d) mh(in=d);&lt;/P&gt;&lt;P&gt;by usubjid;&lt;/P&gt;&lt;P&gt;if a and (b or c or d);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 12:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-way-to-use-joins-instead-of-merge-for-below-code/m-p/739196#M230681</guid>
      <dc:creator>rajeshV89</dc:creator>
      <dc:date>2021-05-05T12:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: What is the way to use joins instead of merge for below code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-way-to-use-joins-instead-of-merge-for-below-code/m-p/739201#M230684</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select a.*
from dm a
where a.usubjid in (
  select distinct usubjid from ae
  union
  select distinct usubjid from cm
  union
  select distinct usubjid from mh
);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need to include additional variables from datasets ae, cm and mh, the whole thing will be a lot more complicated.&lt;/P&gt;
&lt;P&gt;The sheer simplicity of the data step code tells you which is the right tool for this task (Maxim 14),&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 12:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-way-to-use-joins-instead-of-merge-for-below-code/m-p/739201#M230684</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-05T12:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: What is the way to use joins instead of merge for below code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-way-to-use-joins-instead-of-merge-for-below-code/m-p/739204#M230687</link>
      <description>if i want to add any variable from ae or cm or cm ...what i mean .... i want to add usubjid, aeterm from ae..... usubjid, mhterm from mh..... also usubjid, cmtrt from cm ....in this case how should i proceed?</description>
      <pubDate>Wed, 05 May 2021 12:49:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-way-to-use-joins-instead-of-merge-for-below-code/m-p/739204#M230687</guid>
      <dc:creator>rajeshV89</dc:creator>
      <dc:date>2021-05-05T12:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: What is the way to use joins instead of merge for below code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-way-to-use-joins-instead-of-merge-for-below-code/m-p/739208#M230690</link>
      <description>&lt;P&gt;Stay with your data step.&lt;/P&gt;
&lt;P&gt;SQL (untested) might look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    dm.*,
    ae.aeterm,
    cm.cmtrt,
    mh.mhterm
  from dm a
  left join ae
  on dm.usubjid = ae.usubjid
  left join cm
  on dm.usubjid = cm.usubjid
  left join mh
  on dm.usibjid = mh.usubjid
  where a.usubjid in (
    select distinct usubjid from ae
    union
    select distinct usubjid from cm
    union
    select distinct usubjid from mh
  )
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I can only repeat the last line of my previous post. Compare the codes, and you'll see that forcing this unto SQL is just pure idiocy.&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 13:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-way-to-use-joins-instead-of-merge-for-below-code/m-p/739208#M230690</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-05T13:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: What is the way to use joins instead of merge for below code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-way-to-use-joins-instead-of-merge-for-below-code/m-p/739214#M230693</link>
      <description>It's working fine..thanks for the information..</description>
      <pubDate>Wed, 05 May 2021 13:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-way-to-use-joins-instead-of-merge-for-below-code/m-p/739214#M230693</guid>
      <dc:creator>rajeshV89</dc:creator>
      <dc:date>2021-05-05T13:25:06Z</dc:date>
    </item>
  </channel>
</rss>

