<?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 Increment in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251215#M47426</link>
    <description>&lt;P&gt;If you have a macro variable that contains an 8 digit string in the format YYYYMMDD you can convert it to an actual date value using the INPUTN() function which you can call using the %SYSFUNC() macro function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let date=%sysfunc(inputn(&amp;amp;fldate,yymmdd8));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will be the number of days since 1/1/1960. If you want it formatted in a particular way you can use the optional format specification on the %SYSFUNC() function call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let datestr=%sysfunc(inputn(&amp;amp;fldate,yymmdd8),date9);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using the value in an expression in SAS code (like an IF or WHERE statement) then you can use either format, but&amp;nbsp;with the second you need to express it in the form of a date literal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where visdate &amp;lt;= &amp;amp;date ;&lt;/P&gt;
&lt;P&gt;where visdate &amp;lt;= &amp;amp;date + 1;&lt;/P&gt;
&lt;P&gt;where visdate &amp;lt;= "&amp;amp;datestr"d ;&lt;/P&gt;
&lt;P&gt;where visdate &amp;lt;= "&amp;amp;datestr"d+1 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to generate the next date using the same YYYYMMDD format then use the PUTN() function and the YYMMDDN format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let nxtdate = %sysfunc(putn(1+%sysfunc(inputn(&amp;amp;fldate,yymmdd8)),yymmddn8));&lt;/P&gt;</description>
    <pubDate>Fri, 19 Feb 2016 17:20:37 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2016-02-19T17:20:37Z</dc:date>
    <item>
      <title>Date Increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251180#M47408</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm creating a date from a file name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Today_chk = %sysfunc(inputn(%qsubstr(&amp;amp;fldate,5,2)%qsubstr(&amp;amp;fldate,7,2)%qsubstr(&amp;amp;fldate,3,2),mmddyy6.),date9.);
%put &amp;amp;Today_chk;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm trying to increment this date by 1 day and can't seem to get it to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried intnx but it doesnt want to work for me.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Today_chk = intnx('day',%sysfunc(inputn(%qsubstr(&amp;amp;fldate,5,2)%qsubstr(&amp;amp;fldate,7,2)%qsubstr(&amp;amp;fldate,3,2),mmddyy6.),date9.),1);
%put &amp;amp;Today_chk;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What am I stumbling on?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 16:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251180#M47408</guid>
      <dc:creator>Ody</dc:creator>
      <dc:date>2016-02-19T16:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: Date Increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251182#M47409</link>
      <description>&lt;P&gt;Show the value of FLDATE.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 16:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251182#M47409</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-19T16:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Date Increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251184#M47413</link>
      <description>&lt;P&gt;Can you show us the value of &amp;amp;fldate ?&lt;/P&gt;
&lt;P&gt;It may be that you can use the pieces without breaking them up using a different informat like YYMMDD6.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 16:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251184#M47413</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-19T16:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Date Increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251190#M47416</link>
      <description>&lt;P&gt;The file name is something like data_file_extract_20160219.tar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;fldate = 20160219. I'm using it in another comparison in my program so I figured I could reuse it for what I'm trying to accomplish here. Ultimately I would like to incrememnt it by 1 day. It has to be a date value becuase I'm evaluating it against another date.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 16:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251190#M47416</guid>
      <dc:creator>Ody</dc:creator>
      <dc:date>2016-02-19T16:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Date Increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251201#M47419</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/29074"&gt;@Ody&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The file name is something like data_file_extract_20160219.tar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;fldate = 20160219. I'm using it in another comparison in my program so I figured I could reuse it for what I'm trying to accomplish here. Ultimately I would like to incrememnt it by 1 day. It has to be a date value becuase I'm evaluating it against another date.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm confused by your last statement as to what kind of date you are talking about. &amp;nbsp;Please provide more details everything and where the comparision of the value of FLDATE+1 will be used. &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 16:36:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251201#M47419</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-19T16:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Date Increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251204#M47421</link>
      <description>&lt;P&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; newdate =&lt;/FONT&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%eval&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;(&lt;/FONT&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;(inputn(&amp;amp;fldate,yymmdd8.)) + 1);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;will create a value for newdate that is a SAS date value.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;I'm not sure that is what you actually want as you were trying to do something with a DATE9 format.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;If you need the result to look like a 20JUN2016&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; newdate =%sysfunc(putn(&lt;/FONT&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%eval&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;(&lt;/FONT&gt;&lt;FONT color="#ff0080" face="SAS Monospace" size="2"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;(inputn(&amp;amp;fldate,yymmdd8.)) + 1)),date9.));&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 16:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251204#M47421</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-19T16:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Date Increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251215#M47426</link>
      <description>&lt;P&gt;If you have a macro variable that contains an 8 digit string in the format YYYYMMDD you can convert it to an actual date value using the INPUTN() function which you can call using the %SYSFUNC() macro function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let date=%sysfunc(inputn(&amp;amp;fldate,yymmdd8));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will be the number of days since 1/1/1960. If you want it formatted in a particular way you can use the optional format specification on the %SYSFUNC() function call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let datestr=%sysfunc(inputn(&amp;amp;fldate,yymmdd8),date9);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using the value in an expression in SAS code (like an IF or WHERE statement) then you can use either format, but&amp;nbsp;with the second you need to express it in the form of a date literal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where visdate &amp;lt;= &amp;amp;date ;&lt;/P&gt;
&lt;P&gt;where visdate &amp;lt;= &amp;amp;date + 1;&lt;/P&gt;
&lt;P&gt;where visdate &amp;lt;= "&amp;amp;datestr"d ;&lt;/P&gt;
&lt;P&gt;where visdate &amp;lt;= "&amp;amp;datestr"d+1 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to generate the next date using the same YYYYMMDD format then use the PUTN() function and the YYMMDDN format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let nxtdate = %sysfunc(putn(1+%sysfunc(inputn(&amp;amp;fldate,yymmdd8)),yymmddn8));&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 17:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251215#M47426</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-02-19T17:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Date Increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251277#M47441</link>
      <description>&lt;P&gt;Many thanks Tom (and Ballardw).&lt;BR /&gt;&lt;BR /&gt;I couldn't quite figure out where to increment the date and your NXTDATE variable was a good example of how I needed to structure the code.&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;edit: In your NXTDATE variable, doesn't the putn change the date back to character or am I missing something?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 20:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Increment/m-p/251277#M47441</guid>
      <dc:creator>Ody</dc:creator>
      <dc:date>2016-02-19T20:41:53Z</dc:date>
    </item>
  </channel>
</rss>

