<?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 equivalent to get previous month from current month date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525965#M143145</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need your help, what is the proc sql&amp;nbsp;equivalent for this sql&amp;nbsp;syntax below :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ON t1.date -&amp;nbsp; EXTRACT(DAY FROM t1.date)= t2.date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This syntax provides data for&amp;nbsp;the prior month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please let me know.&lt;/P&gt;&lt;P&gt;thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jan 2019 03:24:00 GMT</pubDate>
    <dc:creator>sufiya</dc:creator>
    <dc:date>2019-01-10T03:24:00Z</dc:date>
    <item>
      <title>Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525965#M143145</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need your help, what is the proc sql&amp;nbsp;equivalent for this sql&amp;nbsp;syntax below :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ON t1.date -&amp;nbsp; EXTRACT(DAY FROM t1.date)= t2.date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This syntax provides data for&amp;nbsp;the prior month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please let me know.&lt;/P&gt;&lt;P&gt;thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 03:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525965#M143145</guid>
      <dc:creator>sufiya</dc:creator>
      <dc:date>2019-01-10T03:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525966#M143146</link>
      <description>&lt;P&gt;The SAS INTNX() function allows you to shift dates (i.e. to the beginning or end of the previous month).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 03:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525966#M143146</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-01-10T03:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525971#M143151</link>
      <description>&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would&amp;nbsp;you know if there is a Proc sql&amp;nbsp;equivalent to the above syntax?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 04:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525971#M143151</guid>
      <dc:creator>sufiya</dc:creator>
      <dc:date>2019-01-10T04:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525973#M143152</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* this is literal conversion */

ON t1.date - day( t1.date)= t2.date

/* you can also use*/

ON Intck('day', t1.date, -day(t1.date)) = t2.date&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 04:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525973#M143152</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2019-01-10T04:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525974#M143153</link>
      <description>&lt;P&gt;I don't know what dialect this is in, but looks like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;t1.date -&amp;nbsp; EXTRACT(DAY FROM t1.date)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;would be equivalent to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;intnx("MONTH", t1.date, -1, "END")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i.e. the last day of the previous month, relative to t1.date.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 04:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525974#M143153</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-01-10T04:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525975#M143154</link>
      <description>&lt;P&gt;it is Teradata&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 04:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525975#M143154</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2019-01-10T04:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525982#M143156</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/191207"&gt;@sufiya&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;So this expression in Teradata gives you the last day of the previous month:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt;t1.date -&amp;nbsp; EXTRACT(DAY FROM t1.date)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so then using SAS function INTNX() as posted by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;will do the same:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT face="courier new,courier"&gt;intnx("MONTH", t1.date, -1, "END")&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the SAS function will work BUT if you still execute this against two tables in Teradata and use this function in a join condition then it could have a negative impact on performance. SAS can't push the INTNX() function to the database side and though will have to load all the data first into SAS before executing the function. Transferring all the data first to the SAS server can potentially create a big overhead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You've got two options to overcome this:&lt;/P&gt;
&lt;P&gt;1. Use explicit pass-through SQL. This allows you to formulate the SQL in Teradata syntax and execute the code directly on the database.&lt;/P&gt;
&lt;P&gt;2. Use SAS SQL flavor BUT only use functions which SAS can push to the database for execution. Here the list of the functions for which this works.&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?docsetId=acreldb&amp;amp;docsetTarget=p0lpu4mxo0lkrcn17ignr2iq9zb3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=acreldb&amp;amp;docsetTarget=p0lpu4mxo0lkrcn17ignr2iq9zb3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For option 2:&lt;/P&gt;
&lt;P&gt;The SAS DAY() function is in the list of functions which SAS can push to the database. You could therefor formulate your expression like:&amp;nbsp;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;EM&gt;t1.date-day(t1.date)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 06:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/525982#M143156</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-01-10T06:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/526256#M143288</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello Kiranv,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your reply.&lt;/P&gt;&lt;P&gt;I added some additional conditions to the syntax but receive a syntax error. Please can you help me understand where I am going wrong with this...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;BR /&gt;ON t1.Name=t1.Name and t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date= t2.date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;day&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; t2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;



ON t1.Name=t2.Name and t1.date= &lt;SPAN class="token function"&gt;Intck&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'day'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; t2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;day&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; t2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 01:44:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/526256#M143288</guid>
      <dc:creator>sufiya</dc:creator>
      <dc:date>2019-01-11T01:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/526262#M143292</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/* I just indented your code

 some where your  third condition is not right
first condition which starts with ON looks syntactically OK
2nd one also looks ok which starts with and
3rd one looks odd, it does not have an and condition and also have does not something to compare to
*/

ON t1.Name=t1.Name 
and t1.date= t2.date - day( t1.date)
= t2.date&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Jan 2019 02:52:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/526262#M143292</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2019-01-11T02:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/526276#M143296</link>
      <description>&lt;P&gt;the condition works in Teradata, I am looking for the proc SQL&amp;nbsp;equivalent of this syntax...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;teradata:&lt;/P&gt;&lt;P&gt;ON&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="http://t1.name/" target="_blank"&gt;t1.name&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;=&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="http://t2.name/" target="_blank"&gt;t2.name&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;AND&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;t1.date - EXTRACT(DAY&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;FROM&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;t1. date) = t2. date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from the example you provided&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token comment"&gt;/* this is literal conversion */&lt;/SPAN&gt;

ON t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;day&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; t2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;

&lt;SPAN class="token comment"&gt;/* you can also use*/&lt;/SPAN&gt;

ON &lt;SPAN class="token function"&gt;Intck&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'day'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;day&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; t2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;used that to get this but it gives a syntax error ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="  language-sas"&gt;&lt;CODE class="  language-sas"&gt;ON t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Name&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;t2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Name and t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Intck&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'day'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; t2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;day&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; t2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 04:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/526276#M143296</guid>
      <dc:creator>sufiya</dc:creator>
      <dc:date>2019-01-11T04:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/526540#M143416</link>
      <description>&lt;P&gt;Don't use INTCK(). The SAS function to shift a date is INTNX(). But as written earlier you should avoid using SAS functions for data base tables which SAS can't push to the data base for execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the SAS DAY() function here. It does&amp;nbsp;the same as the Teradata EXTRACT function with the DAY keyword.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ON t1.name = t2.name AND t1.date - DAY(t1.date) = t2.date&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jan 2019 00:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/526540#M143416</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-01-12T00:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL equivalent to get previous month from current month date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/526773#M143526</link>
      <description>&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the join syntax as you suggested, didn't&amp;nbsp;receive any error messages but it doesn't&amp;nbsp;show the previous month data is blank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;ON t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; t2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;name AND t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;DAY&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;t1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; t2&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is the data i get back..&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;ThisMonth&lt;/TD&gt;&lt;TD&gt;LastMonth&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Cheerios&lt;/TD&gt;&lt;TD&gt;30-Nov-18&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Lucky&lt;/TD&gt;&lt;TD&gt;30-Nov-18&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which doesn't&amp;nbsp;seem correct, as it isn't&amp;nbsp;showing previous month data.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Jan 2019 20:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-equivalent-to-get-previous-month-from-current-month/m-p/526773#M143526</guid>
      <dc:creator>sufiya</dc:creator>
      <dc:date>2019-01-13T20:45:54Z</dc:date>
    </item>
  </channel>
</rss>

