<?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 Enterprise Guide 7.1: %SYSFUNC INTNX - Unexpected output in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-7-1-SYSFUNC-INTNX-Unexpected-output/m-p/388754#M25067</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like your calculation of &amp;amp;EndDate is doing what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;20   %let report_date = 17.08.2017;
21   %let EndDate = %sysfunc(inputn(&amp;amp;report_date,ddmmyy10.),yymmddn8.);
22   %put &amp;amp;=EndDate;
ENDDATE=20170817

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you compute the StartDate via INTNX(), INTNX() needs a date value to use as a base for the calculation.&amp;nbsp; You gave it EndDate, which has a value of 20170817 which you know means August 17, 2017, but in SAS that number represents a date that is twenty million days after Jan 1, 1960.&amp;nbsp; Apparently that date is too far into the future to be valid for INTNX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the answer is to convert your value 20170817 back into the SAS date for August 17, 2017, which you can do by using the inputn() function again:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;23   %let StartDate = %sysfunc(intnx(month,%sysfunc(inputn(&amp;amp;EndDate,yymmdd8.)),-12,b),yymmddn8.);
24   %put &amp;amp;=StartDate;
STARTDATE=20160801
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 17 Aug 2017 12:23:21 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2017-08-17T12:23:21Z</dc:date>
    <item>
      <title>SAS Enterprise Guide 7.1: %SYSFUNC INTNX - Unexpected output</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-7-1-SYSFUNC-INTNX-Unexpected-output/m-p/388739#M25065</link>
      <description>&lt;P&gt;Hey Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to use create to macro variables with an enddate and startdate in the format 20170817 for Aug, 17, 2017. The "initial" variable report_date is in the format 17.08.2017.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Variables */
%let report_date = 17.08.2017;
%let EndDate = %sysfunc(inputn(&amp;amp;report_date,ddmmyy10.),yymmddn8.);
%let StartDate = %sysfunc(intnx(month,&amp;amp;EndDate,-12,b),yymmddn8.);
%put &amp;amp;StartDate;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, I get this warning:&lt;/P&gt;&lt;P&gt;WARNING: An argument to the function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OK. Does not work. I think the format 2017-08-17 would also be ok. So I change the code to:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Variables */
%let report_date = 17.08.2017;
%let EndDate = %sysfunc(inputn(&amp;amp;report_date,ddmmyy10.),yymmdd10.);
%let StartDate = %sysfunc(intnx(month,&amp;amp;EndDate,-12,b),yymmdd10.);
%put &amp;amp;StartDate;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Ok. It runs without a warning. Here is the output:&lt;/P&gt;&lt;P&gt;1964-06-01&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me with that? Ideally with Plan A.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 11:50:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-7-1-SYSFUNC-INTNX-Unexpected-output/m-p/388739#M25065</guid>
      <dc:creator>AndreasF</dc:creator>
      <dc:date>2017-08-17T11:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Enterprise Guide 7.1: %SYSFUNC INTNX - Unexpected output</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-7-1-SYSFUNC-INTNX-Unexpected-output/m-p/388754#M25067</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like your calculation of &amp;amp;EndDate is doing what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;20   %let report_date = 17.08.2017;
21   %let EndDate = %sysfunc(inputn(&amp;amp;report_date,ddmmyy10.),yymmddn8.);
22   %put &amp;amp;=EndDate;
ENDDATE=20170817

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you compute the StartDate via INTNX(), INTNX() needs a date value to use as a base for the calculation.&amp;nbsp; You gave it EndDate, which has a value of 20170817 which you know means August 17, 2017, but in SAS that number represents a date that is twenty million days after Jan 1, 1960.&amp;nbsp; Apparently that date is too far into the future to be valid for INTNX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the answer is to convert your value 20170817 back into the SAS date for August 17, 2017, which you can do by using the inputn() function again:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;23   %let StartDate = %sysfunc(intnx(month,%sysfunc(inputn(&amp;amp;EndDate,yymmdd8.)),-12,b),yymmddn8.);
24   %put &amp;amp;=StartDate;
STARTDATE=20160801
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 12:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-7-1-SYSFUNC-INTNX-Unexpected-output/m-p/388754#M25067</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-08-17T12:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Enterprise Guide 7.1: %SYSFUNC INTNX - Unexpected output</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-7-1-SYSFUNC-INTNX-Unexpected-output/m-p/388756#M25068</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let report_date = 17.08.2017;
%let EndDate = %sysfunc(inputn(&amp;amp;report_date,ddmmyy10.),yymmddn8.);

%let _EndDate = %sysfunc(inputn(&amp;amp;report_date,ddmmyy10.));
%let StartDate = %sysfunc(intnx(month,&amp;amp;_EndDate,-12,b),yymmddn8.);
%put &amp;amp;StartDate;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 12:30:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-7-1-SYSFUNC-INTNX-Unexpected-output/m-p/388756#M25068</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-08-17T12:30:18Z</dc:date>
    </item>
  </channel>
</rss>

