全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1505 3
2013-03-17
悬赏 20 个论坛币 已解决
%macro a;
%let a=2;%let b=-2;%let c=-2.38050453744706;
%if &a>0 %then %put &a;
%if &b>0 %then %put &b;
%if &c>0 %then %put &c;
%mend;
%a;

如上程序,请问,为什么 c 没有被put出来?谢谢

********补充**************8;

我自己有个解决方案,钻了个空子:
%macro a;
%let a=2;%let b=-2;%let c=-2.38050453744706;
%if &a>0 %then %put &a;
%if &b>0 %then %put &b;
%if %substr(&c,1,2)>0 %then %put &c;   *这样就不报错了;
%mend;
%a;

最佳答案

bobguy 查看完整内容

SAS implicitly uses %eval function to do a comparison in SAS macro language. This is correct when all elements are inters. Otherwise one needs to use %syaevalf if any of them is a floating number. %macro a; %let a=1;%let b=-2;%let c=2.38050453744706; %if %sysevalf(&a>0) %then %put &a; %if %sysevalf(&b>0) %then %put &b; %if %sysevalf(&c>0) %then %put &c; %mend; %a;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-3-17 15:04:38
SAS  implicitly uses %eval function to do a comparison in SAS macro language. This is correct when all elements are inters. Otherwise one needs to use %syaevalf if any of them is a floating number.


%macro a;
%let a=1;%let b=-2;%let c=2.38050453744706;
%if %sysevalf(&a>0) %then %put &a;
%if %sysevalf(&b>0) %then %put &b;
%if %sysevalf(&c>0) %then %put &c;
%mend;
%a;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-3-17 15:29:12
C=-2.38050453744706 ,小于0,为什么会PUT 出来?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-3-17 22:16:38

%macro a;
%let a=2;%let b=-2;%let c=-2.38050453744706;
%if &a>0 %then %put &a;
%if &b>0 %then %put &b;
%if %sysevalf(&c,boolean)>0 %then %put &c;   /*Use %SYSEVALF(expression<, conversion-type>)*/
%mend;
%a;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群