<?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 macro error with date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427336#M105374</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/186420"&gt;@pradark1&lt;/a&gt;&amp;nbsp;No problem, I will have to eat lots of carrots and vitamin A supplements for my eyes to stay alert for such nested syntax. lol&lt;/P&gt;&lt;P&gt;Just be aware, when you are dealing with macro processor, be alert with use of literal tokens 'blahblahblah' or "&lt;SPAN&gt;blahblahblah" . Until your program is executed by macro processor before the resolved&amp;nbsp;text moves to the compiler for datastep execution, we play only with text and temporary conversion of text to numbers.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Knowledge of tokenisation is most important to make the distinction what happens in the input stack. &lt;/EM&gt;I&lt;/STRONG&gt;n&amp;nbsp; my opinion, nobody has mastered this concept to the extent of Ian Whitlock the genius. I am fortunate to even read his paper. Have a good day!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jan 2018 19:39:47 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-01-12T19:39:47Z</dc:date>
    <item>
      <title>SAS macro error with date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427321#M105367</link>
      <description>&lt;P&gt;I am trying to create last date of the month using sas macro. I set year-month yyyymm and would like to get last date of the month. For example if the year is 2015 and month is January, then I would like the SAS date macro variable to be the sas date number equivalent of &amp;nbsp;‘31Jan2015’d&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET YYYYMM = 201501;
%LET SASDATE = %EVAL(%SYSFUNC(INTNX('MONTH',%SYSFUNC(MDY(%SYSFUNC(MOD(&amp;amp;YYYYMM,100)),1,%SYSFUNC(ROUND(%EVAL(&amp;amp;YYYYMM/100))))),1))-1);
%PUT &amp;amp;SASDATE;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am getting the following error in the log. Can you please help? Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;23&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GOPTIONS ACCESSIBLE;
24&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET YYYYMM = 201501;
25&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %LET SASDATE =
25&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ! %EVAL(%SYSFUNC(INTNX('MONTH',%SYSFUNC(MDY(%SYSFUNC(MOD(&amp;amp;YYYYMM,100)),1,%SYSFUNC(ROUND(%EVAL(&amp;amp;YYYYMM/100))))),1))-1);
WARNING: Argument 1 to function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.
NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;to a missing value.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.-1
26&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %PUT &amp;amp;SASDATE;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 19:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427321#M105367</guid>
      <dc:creator>pradark1</dc:creator>
      <dc:date>2018-01-12T19:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro error with date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427323#M105368</link>
      <description>&lt;P&gt;Ah yes, doing it this way requires multiple %sysfunc nested within each other, it's a nightmare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead do it in a data step, no more %sysfunc needed, makes your life a whole lot easier, or at least easier to debug.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    date_desired = .... your code here .... ;
    call symputx( 'sasdate',date_desired);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Jan 2018 19:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427323#M105368</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-01-12T19:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro error with date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427327#M105370</link>
      <description>&lt;P&gt;I can't agree more with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; My eyes and head&amp;nbsp; hurt&amp;nbsp; to review the syntax&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 19:16:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427327#M105370</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-12T19:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro error with date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427331#M105371</link>
      <description>&lt;P&gt;OK, removing the quotes around 'MONTH' solves your problem&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%LET YYYYMM = 201501;&lt;BR /&gt;%LET SASDATE = %EVAL(%SYSFUNC(INTNX(&lt;STRONG&gt;MONTH&lt;/STRONG&gt;,%SYSFUNC(MDY(%SYSFUNC(MOD(&amp;amp;YYYYMM,100)),1,%SYSFUNC(ROUND(%EVAL(&amp;amp;YYYYMM/100))))),1))-1);&lt;BR /&gt;%PUT &amp;amp;SASDATE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note: You do not require quotes or in other words literal tokens for the macro processor to do text processing&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 19:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427331#M105371</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-12T19:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro error with date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427332#M105372</link>
      <description>Thanks, I agree. It is cleaner to code in a data step.</description>
      <pubDate>Fri, 12 Jan 2018 19:29:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427332#M105372</guid>
      <dc:creator>pradark1</dc:creator>
      <dc:date>2018-01-12T19:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro error with date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427333#M105373</link>
      <description>Thanks for that solution. I could not have guessed it. It work with quotes outside of macro environment.</description>
      <pubDate>Fri, 12 Jan 2018 19:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427333#M105373</guid>
      <dc:creator>pradark1</dc:creator>
      <dc:date>2018-01-12T19:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro error with date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427336#M105374</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/186420"&gt;@pradark1&lt;/a&gt;&amp;nbsp;No problem, I will have to eat lots of carrots and vitamin A supplements for my eyes to stay alert for such nested syntax. lol&lt;/P&gt;&lt;P&gt;Just be aware, when you are dealing with macro processor, be alert with use of literal tokens 'blahblahblah' or "&lt;SPAN&gt;blahblahblah" . Until your program is executed by macro processor before the resolved&amp;nbsp;text moves to the compiler for datastep execution, we play only with text and temporary conversion of text to numbers.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Knowledge of tokenisation is most important to make the distinction what happens in the input stack. &lt;/EM&gt;I&lt;/STRONG&gt;n&amp;nbsp; my opinion, nobody has mastered this concept to the extent of Ian Whitlock the genius. I am fortunate to even read his paper. Have a good day!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 19:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-error-with-date/m-p/427336#M105374</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-12T19:39:47Z</dc:date>
    </item>
  </channel>
</rss>

