<?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: Proc sql to join three tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-to-join-three-tables/m-p/629941#M186429</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What join do you need? INNER or LEFT. For me it looks like you need an inner join for your requirement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
Create table NWHC_DAD as 
Select distinct
A.*
From NWHC_service as A
inner join DAD as D On A.ID=D.ID and A.ID&amp;lt;&amp;gt;'9999999999'
inner join NRS as N On A.ID=N.ID and A.ID&amp;lt;&amp;gt;'9999999999'

Where D.fyear=2016 and ( A.days_to_servdate&amp;lt;=N.days_to_servdate or A.days_to_servdate&amp;lt;=D.days_to_servdate)
;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 05 Mar 2020 20:22:50 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2020-03-05T20:22:50Z</dc:date>
    <item>
      <title>Proc sql to join three tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-to-join-three-tables/m-p/629930#M186422</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
Create table NWHC_DAD as 
Select distinct
A.*
From NWHC_service as A
Left join DAD as D
On A.ID=D.ID and A.ID~=’9999999999’
Where D.fyear=2016 and A.days_to_servdate&amp;lt;=D.days_to_servdate+60
;quit;

Proc sql;
Create table NWHC_NRS as 
Select distinct
A.*
From NWHC_service as A
Left join NRS as N
On A.ID=N.ID and A.ID~=’9999999999’
Where D.fyear=2016 and A.days_to_servdate&amp;lt;=N.days_to_servdate+60
;quit;


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;I need to combine the three tables in one step so that I have a final table which has the IDs where the foll condition is satisfied along with the other conditions in the query : days_to_servdate from the A table is &amp;lt;= days_to servdate from table D or days_to servdate From table N &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Please advise how would i do that&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 19:49:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-to-join-three-tables/m-p/629930#M186422</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2020-03-05T19:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql to join three tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-to-join-three-tables/m-p/629933#M186424</link>
      <description>&lt;P&gt;Joining three tables&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=sqlproc&amp;amp;docsetTarget=p0xbwe8mkbjx9zn1fkxw7skq9efd.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=sqlproc&amp;amp;docsetTarget=p0xbwe8mkbjx9zn1fkxw7skq9efd.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 19:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-to-join-three-tables/m-p/629933#M186424</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-05T19:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql to join three tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-to-join-three-tables/m-p/629941#M186429</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What join do you need? INNER or LEFT. For me it looks like you need an inner join for your requirement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
Create table NWHC_DAD as 
Select distinct
A.*
From NWHC_service as A
inner join DAD as D On A.ID=D.ID and A.ID&amp;lt;&amp;gt;'9999999999'
inner join NRS as N On A.ID=N.ID and A.ID&amp;lt;&amp;gt;'9999999999'

Where D.fyear=2016 and ( A.days_to_servdate&amp;lt;=N.days_to_servdate or A.days_to_servdate&amp;lt;=D.days_to_servdate)
;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Mar 2020 20:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-to-join-three-tables/m-p/629941#M186429</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2020-03-05T20:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql to join three tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-to-join-three-tables/m-p/629956#M186441</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table NWHC_DAD_NRS as
select distinct 
A.* 
from NWHC_service as A
left join DAD as D
on A.ID=D.ID and A.ID~='999999999'
where A.days_to_servdate &amp;lt;=D.days_to_admdate+60 and fyear_ddate=2016
left join NRSdisrecs as N
on A.ID=D.ID and N.ID~='999999999'
where A.days_to_servdate &amp;lt;=N.days_to_admdate+60 and fyear_ddate=2016
group by id
order by id
;quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I wanted to do a left join to keep all records in A&lt;/P&gt;&lt;P&gt;Please advise how would i correc the query above to apply all the conditions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 21:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-to-join-three-tables/m-p/629956#M186441</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2020-03-05T21:12:07Z</dc:date>
    </item>
  </channel>
</rss>

