<?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 Proc sql conditional join in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-conditional-join/m-p/284198#M57980</link>
    <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a first dataset that has the member number, groupnum , benpkg and other fields.&lt;/P&gt;
&lt;P&gt;In the second table also&amp;nbsp;i have the group_id, benpkg and other fields ( seperated as two tables based on the group_id&amp;nbsp;&amp;nbsp;as EP_IN and second table as EP_NOTIN)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We need to use the below condition:&lt;/P&gt;
&lt;P&gt;1. If group_ID includes “EP”, ie like “EP$”, which means that it’s a EP plan, then we need to join on &lt;STRONG&gt;both grpnum= names.group_ID and benpkg=names.Benefit_Package_ID&lt;/STRONG&gt;, both grpnum and benpkg are in the members tables&lt;/P&gt;
&lt;P&gt;2. If it’s not a EP plan, then we &lt;STRONG&gt;only&lt;/STRONG&gt; need to join on &amp;nbsp;grpnum= names.group_Id.&lt;/P&gt;
&lt;P&gt;3. Please use &lt;STRONG&gt;left join&lt;/STRONG&gt;, so that we will still keep the records if there is no matching at names table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;My logic:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;proc &lt;/STRONG&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;create&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; new_members_detail_fl_3 &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#008080"&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;M.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;*,E.Benefit_Package_Name,E.Group_ID&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; new_members_detail_fl_2 M &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;left&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;join&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; EP_IN E&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;on&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; M.grpnum=E.group_ID &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;and&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; M.benpkg=E.Benefit_Package_ID;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;sql&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;create&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; new_members_detail_fl_4 &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#008080"&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;M.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;*, E.Benefit_Package_Name,E.Group_ID&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; new_members_detail_fl_2 M &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;left&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;join&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; EP_NOTIN E&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;on&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; M.grPnum=E.group_ID;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;Can you please let me know how to implement this join condition in the single data step instead of twice.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jul 2016 21:42:58 GMT</pubDate>
    <dc:creator>cho16</dc:creator>
    <dc:date>2016-07-13T21:42:58Z</dc:date>
    <item>
      <title>Proc sql conditional join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-conditional-join/m-p/284198#M57980</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a first dataset that has the member number, groupnum , benpkg and other fields.&lt;/P&gt;
&lt;P&gt;In the second table also&amp;nbsp;i have the group_id, benpkg and other fields ( seperated as two tables based on the group_id&amp;nbsp;&amp;nbsp;as EP_IN and second table as EP_NOTIN)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We need to use the below condition:&lt;/P&gt;
&lt;P&gt;1. If group_ID includes “EP”, ie like “EP$”, which means that it’s a EP plan, then we need to join on &lt;STRONG&gt;both grpnum= names.group_ID and benpkg=names.Benefit_Package_ID&lt;/STRONG&gt;, both grpnum and benpkg are in the members tables&lt;/P&gt;
&lt;P&gt;2. If it’s not a EP plan, then we &lt;STRONG&gt;only&lt;/STRONG&gt; need to join on &amp;nbsp;grpnum= names.group_Id.&lt;/P&gt;
&lt;P&gt;3. Please use &lt;STRONG&gt;left join&lt;/STRONG&gt;, so that we will still keep the records if there is no matching at names table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;My logic:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;proc &lt;/STRONG&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;create&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; new_members_detail_fl_3 &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#008080"&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;M.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;*,E.Benefit_Package_Name,E.Group_ID&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; new_members_detail_fl_2 M &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;left&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;join&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; EP_IN E&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;on&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; M.grpnum=E.group_ID &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;and&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; M.benpkg=E.Benefit_Package_ID;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;sql&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;create&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; new_members_detail_fl_4 &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#008080"&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;M.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;*, E.Benefit_Package_Name,E.Group_ID&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; new_members_detail_fl_2 M &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;left&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;join&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; EP_NOTIN E&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;on&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; M.grPnum=E.group_ID;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;Can you please let me know how to implement this join condition in the single data step instead of twice.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 21:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-conditional-join/m-p/284198#M57980</guid>
      <dc:creator>cho16</dc:creator>
      <dc:date>2016-07-13T21:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql conditional join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-conditional-join/m-p/284201#M57982</link>
      <description>&lt;P&gt;One way to achieve such a one-step join is to load the second data set in 2 different hash tables, one with one key and one with 2 keys. &lt;BR /&gt;And call the find function corresponding to the GROUP_ID&amp;nbsp; (or maybe can you just use 2 keys but one is empty?)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another way is to run a SQL query that contain 2 left join&amp;nbsp;like yours and a union between the joins. The first join would be for group_ID includes “EP”&amp;nbsp; and the second one for group_ID doesn't&amp;nbsp;include “EP”.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 21:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-conditional-join/m-p/284201#M57982</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-07-13T21:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql conditional join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-conditional-join/m-p/284204#M57983</link>
      <description>&lt;P&gt;Seems like you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table new_members_detail_fl_4 as
select 
	M.*,
	coalesce(E.Benefit_Package_Name, F.Benefit_Package_Name) as Benefit_Package_Name,
	coalesce(E.Group_ID, F.Group_ID) as Group_ID
 from 
	new_members_detail_fl_2 as M left join 
	(select * from EP_IN  as E where Group_ID eqt "EP") on M.grpNum=E.Group_ID and M.benpkg=E.Benefit_Package_ID left join
	(select * from EP_NOTIN as F where Group_ID net "EP") on M.grpNum=F.Group_ID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 22:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-conditional-join/m-p/284204#M57983</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-07-13T22:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql conditional join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-conditional-join/m-p/284233#M58001</link>
      <description>&lt;P&gt;Thank You ! the logic works perfectly&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 02:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-conditional-join/m-p/284233#M58001</guid>
      <dc:creator>cho16</dc:creator>
      <dc:date>2016-07-14T02:25:25Z</dc:date>
    </item>
  </channel>
</rss>

