Hi there,
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 ). Can you please point out my mistake? Or is there a glitch in sas? Any help or any comment is highly appreciated. Thanks a lot for your help!
first set of codes:
Looks right to me.
The string 01NOV2025 is definitely less than the string 21SEP2025 since the digit 0 is less than the digit 2.
If you wanted to compare two dates you could either remove the formatting when generating the macro variables.
%let today = %sysfunc(today());
%let Ichoose = %sysevalf('01Nov2025'd);
Then your comparison would be comparing two digit strings so %SYSEVALF() would treat them as numbers.
Or leave the macro variables the same and instead convert the values to date literals when doing the comparison.
%if %sysevalf("&today"d < "&Ichoose"d) %then %do ;
Looks right to me.
The string 01NOV2025 is definitely less than the string 21SEP2025 since the digit 0 is less than the digit 2.
If you wanted to compare two dates you could either remove the formatting when generating the macro variables.
%let today = %sysfunc(today());
%let Ichoose = %sysevalf('01Nov2025'd);
Then your comparison would be comparing two digit strings so %SYSEVALF() would treat them as numbers.
Or leave the macro variables the same and instead convert the values to date literals when doing the comparison.
%if %sysevalf("&today"d < "&Ichoose"d) %then %do ;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.