<?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: SAS dates - within last 3 months in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-within-last-3-months/m-p/339978#M77635</link>
    <description>&lt;P&gt;SAS stores dates as referring to a particular day. &amp;nbsp;So TODAY()-3 is three days earlier. &amp;nbsp;Change it to something like TODAY()-90 and you should be fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's possible (can't test it right now) that you can't use BETWEEN in an IF statement. &amp;nbsp;That's easy enough to change:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if TODAY()-90 &amp;lt;= TXN_DATE &amp;lt;= TODAY() then R_SCORE=50;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2017 12:32:42 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-03-10T12:32:42Z</dc:date>
    <item>
      <title>SAS dates - within last 3 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-within-last-3-months/m-p/339975#M77632</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data step whereby I'm selecting around 50,000 customers. In the output file I have date fields (DATE9.) and I want to create an if statement that will create a value for only those dates which fall in the last 3 months. So far I have the below, please advise where I'm going wrong and how I can do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF TXN_DATE BETWEEN TODAY() AND TODAY()-3 THEN DO;R_SCORE=50;END;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 12:27:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-within-last-3-months/m-p/339975#M77632</guid>
      <dc:creator>CamRutherford</dc:creator>
      <dc:date>2017-03-10T12:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates - within last 3 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-within-last-3-months/m-p/339978#M77635</link>
      <description>&lt;P&gt;SAS stores dates as referring to a particular day. &amp;nbsp;So TODAY()-3 is three days earlier. &amp;nbsp;Change it to something like TODAY()-90 and you should be fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's possible (can't test it right now) that you can't use BETWEEN in an IF statement. &amp;nbsp;That's easy enough to change:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if TODAY()-90 &amp;lt;= TXN_DATE &amp;lt;= TODAY() then R_SCORE=50;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 12:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-within-last-3-months/m-p/339978#M77635</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-10T12:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates - within last 3 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-within-last-3-months/m-p/339979#M77636</link>
      <description>&lt;P&gt;Don't shout your code. Normal speech is sufficient (don't write code in all capitals, for readability)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The between operator is only available in where conditions, use this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if intnx('month',today(),-3,'same') &amp;lt;= txn_date &amp;lt;=today()
then do;
  r_score = 50;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Assuming that txn_date is a SAS date value, of course&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 12:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-within-last-3-months/m-p/339979#M77636</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-10T12:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates - within last 3 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-within-last-3-months/m-p/339981#M77637</link>
      <description>Legend - thank you</description>
      <pubDate>Fri, 10 Mar 2017 12:36:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-within-last-3-months/m-p/339981#M77637</guid>
      <dc:creator>CamRutherford</dc:creator>
      <dc:date>2017-03-10T12:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates - within last 3 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-within-last-3-months/m-p/339985#M77640</link>
      <description>&lt;P&gt;Just to note&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;, that is assuming a base value of 30 days per month. &amp;nbsp;That may not be entirely acurate. &amp;nbsp;I would suggest using the function for it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if intnx('month',today(),-3) &amp;lt;= txn_date &amp;lt;= today() then r_score=50;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Mar 2017 12:45:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-within-last-3-months/m-p/339985#M77640</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-10T12:45:56Z</dc:date>
    </item>
  </channel>
</rss>

