<?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: intnx as macro variable issue in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/566994#M34011</link>
    <description>Hello Kurt,&lt;BR /&gt;It would be a variable from the prompt (12 in this case). I also tried putting a number (11) and the same issue is happening.&lt;BR /&gt;Let me know if you need any further clarification and thank you for your time.</description>
    <pubDate>Tue, 18 Jun 2019 18:37:15 GMT</pubDate>
    <dc:creator>DRivas10</dc:creator>
    <dc:date>2019-06-18T18:37:15Z</dc:date>
    <item>
      <title>intnx as macro variable issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/566988#M34008</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to this community and I would like to ask for your help because I've been trying for 2h and I can't manage to solve my problem.&lt;/P&gt;&lt;P&gt;My goal&amp;nbsp; is that from a date that you introduce in a prompt (201803), you get the same date but 11 months before (201704) in this case.&lt;/P&gt;&lt;P&gt;I'd like to do the task as a macro variable because with a data procedure I don't know how to create a variable to use in open code out of it.&lt;/P&gt;&lt;P&gt;The code I'm currently using is the following:&lt;/P&gt;&lt;P&gt;%let end=201803;&lt;/P&gt;&lt;P&gt;%let aux=%sysfunc(inputn(&amp;amp;end,yymmn6.),ddmmyy8.);&lt;/P&gt;&lt;P&gt;%let start_aux=%sysfunc(intnx(month,&amp;amp;aux,-&amp;amp;sample_size.+1,same),ddmmyy8.);&lt;/P&gt;&lt;P&gt;%let start_aux1=%sysfunc(inputn(&amp;amp;start_aux.,ddmmyy8.),yymmn6.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I go to the journal after doing some puts I get the following:&lt;/P&gt;&lt;P&gt;61&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;aux.;&lt;/P&gt;&lt;P&gt;01/03/18&lt;/P&gt;&lt;P&gt;62&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;start_aux.;&lt;/P&gt;&lt;P&gt;01/02/59&lt;/P&gt;&lt;P&gt;63&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;start_aux1.;&lt;/P&gt;&lt;P&gt;195902&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could please anyone help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 18:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/566988#M34008</guid>
      <dc:creator>DRivas10</dc:creator>
      <dc:date>2019-06-18T18:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: intnx as macro variable issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/566990#M34009</link>
      <description>&lt;P&gt;What is stored in &amp;amp;sample_size?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 18:27:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/566990#M34009</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-18T18:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: intnx as macro variable issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/566992#M34010</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let end=201803;
%let aux=%sysfunc(inputn(&amp;amp;end,yymmn6.),ddmmyy8.);

%let start_aux=%sysfunc(intnx(month,(%sysfunc(inputn(&amp;amp;end,yymmn6.))), -11,same),ddmmyy8.);
%let start_aux1=%sysfunc(inputn(&amp;amp;start_aux.,ddmmyy8.),yymmn6.);

%PUT &amp;amp;end.;
%put &amp;amp;aux.;				/*	01/03/18	*/
%put &amp;amp;start_aux.;		/* 	01/02/59	*/
%put &amp;amp;start_aux1.;		/*	195902		*/

	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I replaced the 'sample size macro logic' with 11 for the purpose of the task requested in your post. You can just plug that logic back in and it should function the same way it is performing now with the '-11' in its place.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 18:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/566992#M34010</guid>
      <dc:creator>tsap</dc:creator>
      <dc:date>2019-06-18T18:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: intnx as macro variable issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/566994#M34011</link>
      <description>Hello Kurt,&lt;BR /&gt;It would be a variable from the prompt (12 in this case). I also tried putting a number (11) and the same issue is happening.&lt;BR /&gt;Let me know if you need any further clarification and thank you for your time.</description>
      <pubDate>Tue, 18 Jun 2019 18:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/566994#M34011</guid>
      <dc:creator>DRivas10</dc:creator>
      <dc:date>2019-06-18T18:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: intnx as macro variable issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/567002#M34012</link>
      <description>&lt;P&gt;Keep in mind that&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the macro preprocessor is a text processing engine and does calculations (on its own) only in some special circumstances&lt;/LI&gt;
&lt;LI&gt;date functions expect raw date values as input&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Try this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let aux=%sysfunc(inputn(&amp;amp;end,yymmn6.));
%let start_aux=%sysfunc(intnx(month,&amp;amp;aux,%eval(-&amp;amp;sample_size.+1),same),ddmmyy8.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jun 2019 18:45:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/567002#M34012</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-18T18:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: intnx as macro variable issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/567047#M34013</link>
      <description>&amp;amp;aux has the wrong value.  It should be unformatted (not using ddmmyy8.) to feed the proper value into INTNX.&lt;BR /&gt;&lt;BR /&gt;In macro language, 01/03/18 becomes 0, the result of %eval(01/03/18)</description>
      <pubDate>Tue, 18 Jun 2019 19:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/567047#M34013</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-06-18T19:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: intnx as macro variable issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/567058#M34014</link>
      <description>&lt;P&gt;Personally, my head always starts to hurt when I get into too many macro functions and variables. It's less sophisticated, but I find a data step clearer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let aux = 201803;

data _null_;
	OriginalDate = mdy(input(substr("&amp;amp;aux.", 5, 2), best2.), 1, input(substr("&amp;amp;aux.", 1, 4), best4.));
	ModifiedDate = intnx("month", OriginalDate, -11, "same");
	call symput("aux1", put(ModifiedDate, yymmn6.));
run;

%put &amp;amp;=aux.;
%put &amp;amp;=aux1.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jun 2019 20:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/567058#M34014</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2019-06-18T20:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: intnx as macro variable issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/567062#M34015</link>
      <description>&lt;P&gt;END does not have a date value, but you are using INPUTN() to convert it into one in some places.&lt;/P&gt;
&lt;P&gt;AUX also does not have a date value, but you are trying to use it as if it did.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why did you use the DDMMYY8 format to set the value of AUX?&amp;nbsp; Do you need that string somewhere else?&amp;nbsp; If so why would you use a date format that does not include the century?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you could either copy&amp;nbsp;the whole %SYSFUNC(INPUTN()) code to convert AUX into a date value where you need a date value.&lt;/P&gt;
&lt;P&gt;Or store the date value into another macro variable and use that one in your calculations and leave AUX and START_AUX for whatever display purpose you need that other string for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like you are trying to do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let end=201803;
%let sample_size=2;
%let start=%sysfunc(intnx(month,%sysfunc(inputn(&amp;amp;end,yymmn6)),-&amp;amp;sample_size+1,s),yymmn6);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;21    %put &amp;amp;=end &amp;amp;=start;
END=201803 START=201802
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 20:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/567062#M34015</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-18T20:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: intnx as macro variable issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/567103#M34018</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/278400"&gt;@DRivas10&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even when starting with a macro variable and wanting a macro variable as result I find it often easier to use a data step in between if there is more than one function involved.&lt;/P&gt;
&lt;P&gt;Below sample code for both a data step approach and a macro only approach.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let end=201803;

data _null_;
  have=input("&amp;amp;end",yymmn6.);
  want=intnx('month',have,-11,'b');
  call symputx('start_aux1',put(want,yymmn6.));
  stop;
run;
%put &amp;amp;=start_aux1;

%let start_aux2=%sysfunc(intnx(month,%sysfunc(inputn(&amp;amp;end,yymmn6.)),-11,b),yymmn6.);
%put &amp;amp;=start_aux2;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jun 2019 00:48:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/intnx-as-macro-variable-issue/m-p/567103#M34018</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-06-19T00:48:22Z</dc:date>
    </item>
  </channel>
</rss>

