楼主: caibirdcnb
4763 3

[问答] 请问高手宏变量如何比较大小? [推广有奖]

  • 0关注
  • 37粉丝

讲师

47%

还不是VIP/贵宾

-

威望
0
论坛币
1367 个
通用积分
16.5538
学术水平
67 点
热心指数
70 点
信用等级
64 点
经验
6762 点
帖子
206
精华
2
在线时间
433 小时
注册时间
2011-8-31
最后登录
2023-9-23

楼主
caibirdcnb 发表于 2016-6-2 15:55:22 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
各位高手,
运行下面程序,结果都是result1,也就是说系统判断21.3<9.6。为什么呢?谢谢!


运行结果:
result1
21.3 9.6
  1. %let SellPrice=21.3;
  2. %let min=9.6;
  3. %macro a;
  4. %if %sysfunc(inputn(&SellPrice,8.))<%sysfunc(inputn(&min,8.)) %then %do;
  5.         %put result1;
  6.         %put %sysfunc(inputn(&SellPrice,8.)) %sysfunc(inputn(&min,8.));
  7. %end;

  8. %if %sysfunc(inputn(&SellPrice,8.))>%sysfunc(inputn(&min,8.)) %then %do;
  9.         %put result2;
  10.         %put %sysfunc(inputn(&SellPrice,8.)) %sysfunc(inputn(&min,8.));
  11. %end;
  12. %mend;
  13. %a

  14. %macro b;
  15. %if &SellPrice<&min %then %do;
  16.         %put result1;
  17.         %put &SellPrice &min;
  18. %end;

  19. %if &SellPrice>&min %then %do;
  20.         %put result2;
  21.         %put &SellPrice &min;
  22. %end;
  23. %mend;
  24. %b

  25. %macro c;
  26. %if &SellPrice>&min %then %do;
  27.         %put result2;
  28.         %put &SellPrice &min;
  29. %end;

  30. %if &SellPrice<&min %then %do;
  31.         %put result1;
  32.         %put &SellPrice &min;
  33. %end;
  34. %mend;
  35. %c
复制代码
二维码

扫码加我 拉你入群

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

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

关键词:Result RESUL Price Sell Rice 如何

沙发
孤单的我们 发表于 2016-6-2 16:08:23
  1. %let SellPrice=21.3;
  2. %let min=9.6;
  3. %macro a;
  4. %if %sysevalf(&SellPrice<&min) %then %do;
  5.         %put result1;
  6.         %put %sysfunc(inputn(&SellPrice,8.)) %sysfunc(inputn(&min,8.));
  7. %end;

  8. %if %sysevalf(&SellPrice>&min) %then %do;
  9.         %put result2;
  10.         %put %sysfunc(inputn(&SellPrice,8.)) %sysfunc(inputn(&min,8.));
  11. %end;
  12. %mend;
  13. %a
复制代码

藤椅
caibirdcnb 发表于 2016-6-2 16:09:39
用%sysevalf(&SellPrice-&min)做判断,可以得到正确结果。

板凳
caibirdcnb 发表于 2016-6-2 16:11:09
楼上的楼上回复的真快,谢谢!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-21 08:04