我正在尝试进行日期比较,但没有得到正确的结果。有谁知道这是怎么回事吗?
%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
宏变量 true 应该等于 1
最佳答案
在这种情况下,您需要使用 %sysevalf() 来评估比较。以下作品。
%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;
关于SAS 全局日期比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31932269/