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 ;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.