<?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: Left Join with where clause in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Left-Join-with-where-clause/m-p/858230#M37901</link>
    <description>&lt;P&gt;or alternatively using the WHERE clause in PROC SQL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
    CREATE TABLE EMPC_VPA AS
        SELECT  T1.VPAA, T1.ST, T1.DATE_OF_APPROVAL,
        T1.DATE_OF_ONBOARD, T1.FIN_EMP_CODE,T1.Emp_Code, T1.target,  
        T2.*
    FROM DST_EMP1 T1
        left join DEC_TXN1 T2
        on T1.VPAA = T2.VPA
    where t1.DATE_OF_APPROVAL between intnx('month', today(), -1, 'B') and intnx('month', today(), -1, 'E');
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please also note the indentation and limiting the amount of text on a given line. This makes the code easier to read and understand. We request you present code in this fashion in the future to help us, and by the way, it will also help you in the long run to make your own code easier to read and understand.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2023 11:31:07 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-02-10T11:31:07Z</dc:date>
    <item>
      <title>Left Join with where clause</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-Join-with-where-clause/m-p/858006#M37882</link>
      <description>&lt;P&gt;I was working on SAS where I have to apply where clause with left join. Kindly, help.&lt;/P&gt;
&lt;P&gt;I want to filer this left join with the function below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where intnx('month', today(), -1, 'B') &amp;lt;= DATE_OF_APPROVAL &amp;lt;= intnx('month', today(), -1, 'E');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to use above code&amp;nbsp; in the Code as below:&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 EMPC_VPA AS
SELECT  T1.VPAA, T1.ST, T1.DATE_OF_APPROVAL, T1.DATE_OF_ONBOARD, T1.FIN_EMP_CODE,T1.Emp_Code, T1.target, T2.*
FROM DST_EMP1 T1 
left join DEC_TXN1 T2 on T1.VPAA =(T2.VPA);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in Advance to all the contributors. Any help is appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 12:40:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-Join-with-where-clause/m-p/858006#M37882</guid>
      <dc:creator>Kirito1</dc:creator>
      <dc:date>2023-02-09T12:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join with where clause</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-Join-with-where-clause/m-p/858012#M37883</link>
      <description>&lt;P&gt;In PROC SQL, you need the BETWEEN syntax&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where DATE_OF_APPROVAL between intnx('month', today(), -1, 'B') and intnx('month', today(), -1, 'E')&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2023 13:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-Join-with-where-clause/m-p/858012#M37883</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-09T13:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join with where clause</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-Join-with-where-clause/m-p/858191#M37899</link>
      <description>&lt;P&gt;I am not sure how to write that in SAS code, I tried putting the where clause on the data(DST_EMP1) but it is giving me an error with the following code as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE EMPC_VPA AS
SELECT  T1.VPAA, T1.ST, T1.DATE_OF_APPROVAL, T1.DATE_OF_ONBOARD, T1.FIN_EMP_CODE,T1.Emp_Code, T1.target, T2.*
FROM DST_EMP1 T1 where DATE_OF_APPROVAL between intnx('month', today(), -1, 'B') and intnx('month', today(), -1, 'E') 
left join DEC_TXN1 T2 on T1.VPAA =(T2.VPA);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Error as below:&lt;/P&gt;
&lt;PRE&gt;PROC SQL;
77    CREATE TABLE EMPC_VPA AS
78    SELECT  T1.VPAA, T1.ST, T1.DATE_OF_APPROVAL, T1.DATE_OF_ONBOARD, T1.FIN_EMP_CODE,T1.Emp_Code, T1.target, T2.*
79    FROM DST_EMP1 T1 where DATE_OF_APPROVAL between intnx('month', today(), -1, 'B') and intnx('month', today(), -1, 'E')
80    left join DEC_TXN1 T2 on T1.VPAA =(T2.VPA);
      ----
      22
      76
ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &amp;amp;, *, **, +, -, /, AND, EXCEPT, GROUP, HAVING, INTERSECT, OR, 
              ORDER, OUTER, UNION, |, ||.  
ERROR 76-322: Syntax error, statement will be ignored.&lt;/PRE&gt;
&lt;P&gt;Kindly, help in correcting the syntax.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 04:55:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-Join-with-where-clause/m-p/858191#M37899</guid>
      <dc:creator>Kirito1</dc:creator>
      <dc:date>2023-02-10T04:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join with where clause</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-Join-with-where-clause/m-p/858206#M37900</link>
      <description>&lt;P&gt;After some tries I got the result. Thank You&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The correct syntax is as below code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE EMPC_VPA AS
SELECT  T1.VPAA, T1.ST, T1.DATE_OF_APPROVAL, T1.DATE_OF_ONBOARD, T1.FIN_EMP_CODE,T1.Emp_Code, T1.target, T2.*
FROM DST_EMP1(where = (DATE_OF_APPROVAL between intnx('month', today(), -1, 'B') and intnx('month', today(), -1, 'E'))) T1
left join DEC_TXN1 T2 on T1.VPAA =(T2.VPA);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Feb 2023 07:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-Join-with-where-clause/m-p/858206#M37900</guid>
      <dc:creator>Kirito1</dc:creator>
      <dc:date>2023-02-10T07:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Left Join with where clause</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Left-Join-with-where-clause/m-p/858230#M37901</link>
      <description>&lt;P&gt;or alternatively using the WHERE clause in PROC SQL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
    CREATE TABLE EMPC_VPA AS
        SELECT  T1.VPAA, T1.ST, T1.DATE_OF_APPROVAL,
        T1.DATE_OF_ONBOARD, T1.FIN_EMP_CODE,T1.Emp_Code, T1.target,  
        T2.*
    FROM DST_EMP1 T1
        left join DEC_TXN1 T2
        on T1.VPAA = T2.VPA
    where t1.DATE_OF_APPROVAL between intnx('month', today(), -1, 'B') and intnx('month', today(), -1, 'E');
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please also note the indentation and limiting the amount of text on a given line. This makes the code easier to read and understand. We request you present code in this fashion in the future to help us, and by the way, it will also help you in the long run to make your own code easier to read and understand.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 11:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Left-Join-with-where-clause/m-p/858230#M37901</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-10T11:31:07Z</dc:date>
    </item>
  </channel>
</rss>

