Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAS Global date comparison

Tags:

sas

I'm trying to do a date comparison but I'm not getting the correct results. Does anyone know what's going on?

%macro ttt;
    %let check_start = 28APR2014;
    %if "&check_start."d < "25may2014"d %then %let true = 1;
    %else %if "&check_start."d > "25may2014"d %then %let true = 2;
    %put &true;
%mend;
%ttt;

14         %macro ttt;
15          %let check_start = 28APR2010;
16          %if "&check_start."d < "25may2014"d %then %let true = 1;
17          %else %if "&check_start."d > "25may2014"d %then %let true = 2;
18          %put &true;
19          %mend;
20          %ttt;
true = 2

Macro-variable true should equal 1

like image 489
Youbloodywombat Avatar asked Dec 06 '25 17:12

Youbloodywombat


1 Answers

You need to use %sysevalf() to evaluate the comparison in this case. The following works.

%macro ttt;
    %let check_start = 28APR2015;
    %if %sysevalf("&check_start"d < '25may2014'd) %then %let true=1;
    %else %if %sysevalf("&check_start."d > '25may2014'd) %then %let true=2;
    %put &true.;
%mend;
%ttt;
like image 185
Reeza Avatar answered Dec 08 '25 09:12

Reeza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!