<?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: Wrong answer generated using  %sysevalf in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Wrong-answer-generated-using-sysevalf/m-p/975438#M11482</link>
    <description>&lt;P&gt;Looks right to me.&lt;/P&gt;
&lt;P&gt;The string&amp;nbsp;&lt;SPAN&gt;01NOV2025 is definitely less than the string 21SEP2025 since the digit 0 is less than the digit 2.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you wanted to compare two dates you could either remove the formatting when generating the macro variables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today = %sysfunc(today());
%let Ichoose = %sysevalf('01Nov2025'd);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Then your comparison would be comparing two digit strings so %SYSEVALF() would treat them as numbers.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Or leave the macro variables the same and instead convert the values to date literals when doing the comparison.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysevalf("&amp;amp;today"d &amp;lt; "&amp;amp;Ichoose"d) %then %do ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 21 Sep 2025 16:14:40 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2025-09-21T16:14:40Z</dc:date>
    <item>
      <title>Wrong answer generated using  %sysevalf</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Wrong-answer-generated-using-sysevalf/m-p/975437#M11481</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I have entered the following 2 sets of codes, even though sas log says there is no syntax error but sas has generated the wrong output for both set of codes(both sets of codes shown below were pasted from sas log ).&amp;nbsp; Can you please point out my mistake?&amp;nbsp; Or is there a glitch in sas? Any help or any comment is highly appreciated. Thanks a lot for your help!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;first set of codes:&lt;/P&gt;&lt;DIV class=""&gt;71 %let today = %sysfunc(today(), date9.);&lt;/DIV&gt;&lt;DIV class=""&gt;72 %put &amp;amp;today;&lt;/DIV&gt;&lt;DIV class=""&gt;21SEP2025&lt;/DIV&gt;&lt;DIV class=""&gt;73 %let Ichoose = %sysfunc(putn('01Nov2025'd, date9.));&lt;/DIV&gt;&lt;DIV class=""&gt;74 %put &amp;amp;Ichoose;&lt;/DIV&gt;&lt;DIV class=""&gt;01NOV2025&lt;/DIV&gt;&lt;DIV class=""&gt;75 %if %sysevalf(&amp;amp;today &amp;lt; &amp;amp;Ichoose) %then %do ;&lt;/DIV&gt;&lt;DIV class=""&gt;76 %put abcd;&lt;/DIV&gt;&lt;DIV class=""&gt;77 %end;&lt;/DIV&gt;&lt;DIV class=""&gt;78 %else %do;&lt;/DIV&gt;&lt;DIV class=""&gt;79 %put efgh ;&lt;/DIV&gt;&lt;DIV class=""&gt;efgh&lt;/DIV&gt;&lt;DIV class=""&gt;80 %end;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;second set of codes:&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;69 %let today = %sysfunc(today(), date9.);&lt;/DIV&gt;&lt;DIV class=""&gt;70 %put &amp;amp;today;&lt;/DIV&gt;&lt;DIV class=""&gt;21SEP2025&lt;/DIV&gt;&lt;DIV class=""&gt;71 %let Ichoose = %sysfunc(putn('01Nov2025'd, date9.));&lt;/DIV&gt;&lt;DIV class=""&gt;72 %put &amp;amp;Ichoose;&lt;/DIV&gt;&lt;DIV class=""&gt;01NOV2025&lt;/DIV&gt;&lt;DIV class=""&gt;73 %if %sysevalf(&amp;amp;today &amp;gt; &amp;amp;Ichoose) %then %do ;&lt;/DIV&gt;&lt;DIV class=""&gt;74 %put abcd;&lt;/DIV&gt;&lt;DIV class=""&gt;abcd&lt;/DIV&gt;&lt;DIV class=""&gt;75 %end;&lt;/DIV&gt;&lt;DIV class=""&gt;76 %else %do;&lt;/DIV&gt;&lt;DIV class=""&gt;77 %put efgh ;&lt;/DIV&gt;&lt;DIV class=""&gt;78 %end;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Sep 2025 16:01:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Wrong-answer-generated-using-sysevalf/m-p/975437#M11481</guid>
      <dc:creator>ssll</dc:creator>
      <dc:date>2025-09-21T16:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong answer generated using  %sysevalf</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Wrong-answer-generated-using-sysevalf/m-p/975438#M11482</link>
      <description>&lt;P&gt;Looks right to me.&lt;/P&gt;
&lt;P&gt;The string&amp;nbsp;&lt;SPAN&gt;01NOV2025 is definitely less than the string 21SEP2025 since the digit 0 is less than the digit 2.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you wanted to compare two dates you could either remove the formatting when generating the macro variables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today = %sysfunc(today());
%let Ichoose = %sysevalf('01Nov2025'd);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Then your comparison would be comparing two digit strings so %SYSEVALF() would treat them as numbers.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Or leave the macro variables the same and instead convert the values to date literals when doing the comparison.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysevalf("&amp;amp;today"d &amp;lt; "&amp;amp;Ichoose"d) %then %do ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Sep 2025 16:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Wrong-answer-generated-using-sysevalf/m-p/975438#M11482</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-21T16:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong answer generated using  %sysevalf</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Wrong-answer-generated-using-sysevalf/m-p/975441#M11483</link>
      <description>Hi Tom, I just tried both of your suggestions in sas, and I got the correct answer . You solved my problem, thanks so very much!</description>
      <pubDate>Sun, 21 Sep 2025 16:48:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Wrong-answer-generated-using-sysevalf/m-p/975441#M11483</guid>
      <dc:creator>ssll</dc:creator>
      <dc:date>2025-09-21T16:48:56Z</dc:date>
    </item>
  </channel>
</rss>

