<?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: Date calculation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/393819#M94881</link>
    <description>&lt;P&gt;Its been asked many times here. &amp;nbsp;The question is why would you need to? &amp;nbsp;You can always get yesterdays date by doing intnx('year',today,-1); so why bother going through all the effort of calculating it, then storing it as text - macro is always text - then trying to use that text in your code. &amp;nbsp;Its madness. &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Sep 2017 10:37:57 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-09-07T10:37:57Z</dc:date>
    <item>
      <title>Date calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/393812#M94877</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to build a macro which shows me current date in datetime format and a date -1 month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date1 = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(datetime(),DATETIME16.);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date_prev=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(intnx(month,"%sysfunc(putn("&amp;amp;date1"d,DATETIME16.))"d,-1,s),DATETIME16.); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;date_prev.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Date1 gives me good results but in date_prev i have 31DEC59:23:53:55. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;How I should change this macro to have date_prev = 07AUG2017time&amp;nbsp;?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 10:12:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/393812#M94877</guid>
      <dc:creator>Jedrzej</dc:creator>
      <dc:date>2017-09-07T10:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: Date calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/393815#M94879</link>
      <description>&lt;P&gt;Why not do it in a data step like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	date1 = datetime();
	date_prev = intnx('dtmonth', date1, -1, 's');
	format date1 date_prev datetime16.;
	put date1= date_prev=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Sep 2017 10:26:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/393815#M94879</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-09-07T10:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Date calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/393819#M94881</link>
      <description>&lt;P&gt;Its been asked many times here. &amp;nbsp;The question is why would you need to? &amp;nbsp;You can always get yesterdays date by doing intnx('year',today,-1); so why bother going through all the effort of calculating it, then storing it as text - macro is always text - then trying to use that text in your code. &amp;nbsp;Its madness. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 10:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/393819#M94881</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-09-07T10:37:57Z</dc:date>
    </item>
  </channel>
</rss>

