楼主: 杨花点点
5141 9

SAS宏SELECT INTO格式问题 [推广有奖]

  • 3关注
  • 17粉丝

已卖:3414份资源

副教授

38%

还不是VIP/贵宾

-

威望
0
论坛币
27519 个
通用积分
9.0463
学术水平
26 点
热心指数
54 点
信用等级
32 点
经验
33317 点
帖子
696
精华
0
在线时间
871 小时
注册时间
2009-7-29
最后登录
2021-10-7

楼主
杨花点点 发表于 2016-2-29 10:24:30 |AI写论文
100论坛币
SAS宏编程中从数据集中选取最小值进入判断语句,但总出错,具体如下:  proc sql noprint;
      select min(signnum) into :sss from sign;
  quit;
  %if &sss<0 %then %do;
  ......


XQ4[UU%TV6DJ~OA[FK73O{B.png
ERROR: 在需要数值操作数的 %EVAL 函数或 %IF 条件中发现字符操作数。条件是: &sss<0
ERROR: 宏 CORRSELECTION 将终止执行。

M@Q[B]GH)8S74}ER1VJP}Q1.png
signnum的格式并不是字符型;

求高人指点!谢谢!








最佳答案

孤单的我们 查看完整内容

逻辑表达式 %if -0.02228 < 0 中,浮点型数值用法有误, 可以用%sysevalf()、或者%if %index(&sss,-) %then %do;
关键词:Select Elect SAS宏 ect LEC

沙发
孤单的我们 发表于 2016-2-29 10:24:31
逻辑表达式 %if  -0.02228 < 0  中,浮点型数值用法有误,
可以用%sysevalf()、或者%if %index(&sss,-) %then %do;

藤椅
孤单的我们 发表于 2016-2-29 14:31:06
%put &sss; 看下&sss的值

板凳
zhengbo8 发表于 2016-2-29 15:14:32
<换成lt

报纸
杨花点点 发表于 2016-2-29 15:20:49
孤单的我们 发表于 2016-2-29 14:31
%put &sss; 看下&sss的值
(03PDZYH`)~KA(5B73GI__V.png

地板
杨花点点 发表于 2016-2-29 15:28:06
zhengbo8 发表于 2016-2-29 15:14
D77G)L}EJR)8`FKS~$L~CKW.png

7
孤单的我们 发表于 2016-2-29 15:35:03
SAS help里的sample:

Comparing Floating Point or Missing Values
You must use the %SYSEVALF function to evaluate logical expressions containing floating point or missing values. To illustrate comparisons with floating point and missing values, consider the following macro that compares parameters passed to it with the %SYSEVALF function and places the result in the log:

%macro compflt(first,second);
   %if %sysevalf(&first>&second) %then %put &first is greater than &second;
   %else %if  %sysevalf(&first=&second) %then %put &first equals &second;
   %else %put %sysevalf(&first is less than &second);
%mend compflt;

Invoking the COMPFLT macro with these values

%compflt (1.2,.9)
%compflt (-.1,.)
%compflt (0,.)

places these values in the log:

1.2 is greater than .9
-.1 is greater than .
0 is greater than .

8
杨花点点 发表于 2016-2-29 15:38:08
孤单的我们 发表于 2016-2-29 15:28
逻辑表达式 %if  -0.02228 < 0有误,
建议用%if %index(&sss,-) %then %do;
谢谢,还想请问一下如果不是判断正负呢,就是进行诸如%if &sss<某个数   这样的判断,有可行的方法吗

9
孤单的我们 发表于 2016-2-29 15:42:16
杨花点点 发表于 2016-2-29 15:38
谢谢,还想请问一下如果不是判断正负呢,就是进行诸如%if &sss
%if %sysevalf(&sss<0) %then %do;

10
杨花点点 发表于 2016-2-29 15:47:04
孤单的我们 发表于 2016-2-29 15:35
SAS help里的sample:

Comparing Floating Point or Missing Values
恩恩,谢啦

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-6 08:24