<?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 Call INTNX FROM %SYSFUNC issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Call-INTNX-FROM-SYSFUNC-issue/m-p/379671#M91395</link>
    <description>&lt;P&gt;Good evening everyone ;&lt;/P&gt;&lt;P&gt;I m having a trouble while callin the INTNX function from %sysfunc which i don't understand&lt;/P&gt;&lt;P&gt;hope you guys help me&lt;/P&gt;&lt;P&gt;Well i have this date&amp;nbsp; date_arr = 30/06/2017 and i want the 3 earlier month date which is the 31/03/2017&lt;/P&gt;&lt;P&gt;so here is my code&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%global arrete ; 
%global date_arr ; 
%global date_hr ; 

%let arrete = 20170630 ; 
%let date_arr = %sysfunc(mdy(%substr(&amp;amp;arrete,5,2),%substr(&amp;amp;arrete,7,2),%substr(&amp;amp;arrete,1,4)), ddmmyy10.);

%put &amp;amp;date_arr. ; 

%let date_hr = %sysfunc(intnx(month, &amp;amp;date_arr, - 3  ,e), ddmmyy10.);

%put  &amp;amp;date_hr. ;&lt;/PRE&gt;&lt;P&gt;Everything works fine , i don't get any errors or warnings but the problem is the value i get for date_hr is 31/10/1959&lt;/P&gt;&lt;P&gt;i share my log too&lt;/P&gt;&lt;PRE&gt; %global arrete ;
118  %global date_arr ;
119  %global date_hr ;
120
121  %let arrete = 20170630 ;
122  %let date_arr = %sysfunc(mdy(%substr(&amp;amp;arrete,5,2),%substr(&amp;amp;arrete,7,2),%substr(&amp;amp;arrete,1,4)),
122! ddmmyy10.);
123
124  %put &amp;amp;date_arr. ;
30/06/2017
125
126  %let date_hr = %sysfunc(intnx(month, &amp;amp;date_arr, - 3  ,e), ddmmyy10.);
127
128  %put la valeur de &amp;amp;date_hr. ;
 31/10/1959&lt;/PRE&gt;&lt;P&gt;thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; :&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jul 2017 11:18:24 GMT</pubDate>
    <dc:creator>Raitag</dc:creator>
    <dc:date>2017-07-27T11:18:24Z</dc:date>
    <item>
      <title>Call INTNX FROM %SYSFUNC issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-INTNX-FROM-SYSFUNC-issue/m-p/379671#M91395</link>
      <description>&lt;P&gt;Good evening everyone ;&lt;/P&gt;&lt;P&gt;I m having a trouble while callin the INTNX function from %sysfunc which i don't understand&lt;/P&gt;&lt;P&gt;hope you guys help me&lt;/P&gt;&lt;P&gt;Well i have this date&amp;nbsp; date_arr = 30/06/2017 and i want the 3 earlier month date which is the 31/03/2017&lt;/P&gt;&lt;P&gt;so here is my code&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%global arrete ; 
%global date_arr ; 
%global date_hr ; 

%let arrete = 20170630 ; 
%let date_arr = %sysfunc(mdy(%substr(&amp;amp;arrete,5,2),%substr(&amp;amp;arrete,7,2),%substr(&amp;amp;arrete,1,4)), ddmmyy10.);

%put &amp;amp;date_arr. ; 

%let date_hr = %sysfunc(intnx(month, &amp;amp;date_arr, - 3  ,e), ddmmyy10.);

%put  &amp;amp;date_hr. ;&lt;/PRE&gt;&lt;P&gt;Everything works fine , i don't get any errors or warnings but the problem is the value i get for date_hr is 31/10/1959&lt;/P&gt;&lt;P&gt;i share my log too&lt;/P&gt;&lt;PRE&gt; %global arrete ;
118  %global date_arr ;
119  %global date_hr ;
120
121  %let arrete = 20170630 ;
122  %let date_arr = %sysfunc(mdy(%substr(&amp;amp;arrete,5,2),%substr(&amp;amp;arrete,7,2),%substr(&amp;amp;arrete,1,4)),
122! ddmmyy10.);
123
124  %put &amp;amp;date_arr. ;
30/06/2017
125
126  %let date_hr = %sysfunc(intnx(month, &amp;amp;date_arr, - 3  ,e), ddmmyy10.);
127
128  %put la valeur de &amp;amp;date_hr. ;
 31/10/1959&lt;/PRE&gt;&lt;P&gt;thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; :&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 11:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-INTNX-FROM-SYSFUNC-issue/m-p/379671#M91395</guid>
      <dc:creator>Raitag</dc:creator>
      <dc:date>2017-07-27T11:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Call INTNX FROM %SYSFUNC issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-INTNX-FROM-SYSFUNC-issue/m-p/379672#M91396</link>
      <description>&lt;P&gt;Very simple (&lt;EM&gt;once you know where to look, of course&lt;/EM&gt; &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; &amp;amp;date_arr is &lt;EM&gt;not&lt;/EM&gt; a SAS date value, but a &lt;EM&gt;representation&lt;/EM&gt; of a SAS date value.&lt;/P&gt;
&lt;P&gt;Omit the format when creating it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let arrete = 20170630 ; 
%let date_arr = %sysfunc(mdy(%substr(&amp;amp;arrete,5,2),%substr(&amp;amp;arrete,7,2),%substr(&amp;amp;arrete,1,4)));

%put &amp;amp;date_arr. ; 

%let date_hr = %sysfunc(intnx(month, &amp;amp;date_arr, - 3  ,e), ddmmyy10.);

%put  &amp;amp;date_hr. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And you'll see that the end result looks fine.&lt;/P&gt;
&lt;P&gt;Moral: look at my Maxim 28. Don't use formats when &lt;EM&gt;values&lt;/EM&gt; are needed.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 11:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-INTNX-FROM-SYSFUNC-issue/m-p/379672#M91396</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-27T11:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Call INTNX FROM %SYSFUNC issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-INTNX-FROM-SYSFUNC-issue/m-p/380169#M91407</link>
      <description>&lt;P&gt;Dates are the number of days since beginning of 1960. &amp;nbsp;Your macro variable looks like this:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;30/06/2017&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So you are asking SAS to divide 30 by 6 and then again by 2017. This is a number close to zero. &amp;nbsp;So you are asking INTNX() it to go back 3 months from Jan 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either pass the INTNX() function actual raw numbers of days or date literals.&lt;/P&gt;
&lt;P&gt;Try this little bit of code using your example date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let arrete = 20170630 ; 
%let date_arr_raw = %sysfunc(inputn(&amp;amp;arrete,yymmdd8));
%let date_arr_lit = "%sysfunc(inputn(&amp;amp;arrete,yymmdd8),date9)"d;
%let date_arr_ymd = %sysfunc(inputn(&amp;amp;arrete,yymmdd8),yymmdd10);
%let date_arr_dmy = %sysfunc(inputn(&amp;amp;arrete,yymmdd8),ddmmyy10);
%let date_arr_mdy = %sysfunc(inputn(&amp;amp;arrete,yymmdd8),mmddyy10);

%put &amp;amp;=arrete
     &amp;amp;=date_arr_raw
     &amp;amp;=date_arr_lit
     &amp;amp;=date_arr_ymd
     &amp;amp;=date_arr_dmy
     &amp;amp;=date_arr_mdy
;

%let date_hr = %sysfunc(intnx(month, &amp;amp;date_arr_raw, - 3  ,e), ddmmyy10.);
%put  &amp;amp;=date_hr. ;

%let date_hr = %sysfunc(intnx(month, &amp;amp;date_arr_lit, - 3  ,e), ddmmyy10.);
%put  &amp;amp;=date_hr. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Results:&lt;/P&gt;
&lt;PRE&gt;ARRETE=20170630      
DATE_ARR_RAW=21000      
DATE_ARR_LIT="30JUN2017"d      
DATE_ARR_YMD=2017-06-30
DATE_ARR_DMY=30/06/2017      
DATE_ARR_MDY=06/30/2017

DATE_HR=31/03/2017

DATE_HR=31/03/2017
&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jul 2017 13:54:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-INTNX-FROM-SYSFUNC-issue/m-p/380169#M91407</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-27T13:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Call INTNX FROM %SYSFUNC issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-INTNX-FROM-SYSFUNC-issue/m-p/383481#M91466</link>
      <description>&lt;P&gt;And perhaps don't use functions when an INFORMAT may work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let arrete = 20170630 ; 
%let date_arr = %sysfunc(mdy(%substr(&amp;amp;arrete,5,2),%substr(&amp;amp;arrete,7,2),%substr(&amp;amp;arrete,1,4)));

%put Date_arr is &amp;amp;date_arr. ; 


%let date_arr2 = %sysfunc(inputn(&amp;amp;arrete.,yymmdd8.));
%put Date_arr2 is &amp;amp;date_arr2.;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jul 2017 20:08:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-INTNX-FROM-SYSFUNC-issue/m-p/383481#M91466</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-27T20:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Call INTNX FROM %SYSFUNC issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-INTNX-FROM-SYSFUNC-issue/m-p/384891#M91997</link>
      <description>Hi ,&lt;BR /&gt;Thank you guys for your help .&lt;BR /&gt;All i had to do is to omit the format as KurtBremser said .&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Aug 2017 08:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-INTNX-FROM-SYSFUNC-issue/m-p/384891#M91997</guid>
      <dc:creator>Raitag</dc:creator>
      <dc:date>2017-08-02T08:48:00Z</dc:date>
    </item>
  </channel>
</rss>

