由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS macro question
相关主题
请教一个SAS Macro的问题sas 代码问题
请教一个SAS 数据分配问题【包子】求问个简单sas macro问题
SAS help : how to macro odsNeed advice on SAS macro debugging
{请教} 一个SAS程序问题一个常见的问题
求助关于sas macro 中的if- then语句请教一道SAS MACRO编程的问题。怎么都不明白。谢谢
Stupid SAS programming style is driving me crazy....请教SAS IML调用DATA step数据的问题
sas macro 问题[Help] Dividing a SAS data set
Weird SAS macro bugs, 包子重谢!请教一个 SAS macro
相关话题的讨论汇总
话题: sysevalf话题: thres话题: intercept话题: intp话题: le
进入Statistics版参与讨论
1 (共1页)
m******m
发帖数: 445
1
%let thres_intp_l=%str(-0.2);
%let intercept=%str(-0.3);
%macro test2;
%if &intercept le &thres_intp_l
%then %put 1;
%else %put 0;
%mend test2;
SAS will output 0 for above. If change to -2 and -3 (integer), the
comparison is correct. How can I get the correct comparison with floating
number?
Thanks!
n******e
发帖数: 53
2
try
%if %SYSEVALF(&intercept) le %SYSEVALF(&thres_intp_l)
k*******a
发帖数: 772
3
can also try
%if %sysevalf(&intercept le &thres_intp_l)
m******m
发帖数: 445
4
have u ever tried this?
I did it but failed. didn't mention in my original post

【在 n******e 的大作中提到】
: try
: %if %SYSEVALF(&intercept) le %SYSEVALF(&thres_intp_l)

D******n
发帖数: 2836
5
try this
%if %sysevalf(&a>&b,boolean)>0 %then .....
this one is tested.
baozi pls.

【在 m******m 的大作中提到】
: have u ever tried this?
: I did it but failed. didn't mention in my original post

a******n
发帖数: 11246
6
其实就是要把字符型的-0.2变为数值型,但我不知道用什么函数。
只会用这个傻x方法解决:(
%if %sysevalf(&intercept+1) le %sysevalf(&thres+1)

【在 m******m 的大作中提到】
: %let thres_intp_l=%str(-0.2);
: %let intercept=%str(-0.3);
: %macro test2;
: %if &intercept le &thres_intp_l
: %then %put 1;
: %else %put 0;
: %mend test2;
: SAS will output 0 for above. If change to -2 and -3 (integer), the
: comparison is correct. How can I get the correct comparison with floating
: number?

m******m
发帖数: 445
7
thanks!

【在 k*******a 的大作中提到】
: can also try
: %if %sysevalf(&intercept le &thres_intp_l)

m******m
发帖数: 445
8
thanks!

【在 D******n 的大作中提到】
: try this
: %if %sysevalf(&a>&b,boolean)>0 %then .....
: this one is tested.
: baozi pls.

m******m
发帖数: 445
9
thanks!

【在 a******n 的大作中提到】
: 其实就是要把字符型的-0.2变为数值型,但我不知道用什么函数。
: 只会用这个傻x方法解决:(
: %if %sysevalf(&intercept+1) le %sysevalf(&thres+1)

l***a
发帖数: 12410
10
+0 中不?

【在 a******n 的大作中提到】
: 其实就是要把字符型的-0.2变为数值型,但我不知道用什么函数。
: 只会用这个傻x方法解决:(
: %if %sysevalf(&intercept+1) le %sysevalf(&thres+1)

w*****5
发帖数: 515
11
晚上看了一点书,分析并总结一下。。不对的地方请大牛指出。
1)%if 其实调用了%eval()来判断表达式
2)%if &intercept le &thres_intp_l相当于%eval( &intercept le &thres_intp_l)
,这个不会出错,因为两个都是字符型,不会自动转换,但是比较结果可能不对。
3)%sysevalf(&intercept le &thres_intp_l)可以得出正确结果,因为%sysevalf(
expression)的结果是1或者0,因此%eval(1)=1, %eval(0)=0
4) 另外3个答案:
%if %sysevalf(&intercept+1) le %sysevalf(&thres+1) 对
%if %sysevalf(&intercept+0) le %sysevalf(&thres+0) 出错
%if %sysevalf(&intercept) le %sysevalf(&thres) 出错
这个比较有意思。因为%if()其实是调用了%eval()
因此,从结果中可以看出,%eval(a》b).如果 a和b是float.
那么如果a,b是正数,结果正确。如果a,b是负数,出错。。
比如把两个数据改成-1.2和-1.3则
%if %sysevalf(&intercept+1) le %sysevalf(&thres+1) 也出错。
这个就不知道为什么了。谁解答一下。
不过,看来,%sysevalf(&intercept le &thres_intp_l)是最好的。
1 (共1页)
进入Statistics版参与讨论
相关主题
请教一个 SAS macro求助关于sas macro 中的if- then语句
请教一个SAS Macro问题。谢谢Stupid SAS programming style is driving me crazy....
请教一个SAS ADV 的题目sas macro 问题
请帮忙看3道SAS题。Weird SAS macro bugs, 包子重谢!
请教一个SAS Macro的问题sas 代码问题
请教一个SAS 数据分配问题【包子】求问个简单sas macro问题
SAS help : how to macro odsNeed advice on SAS macro debugging
{请教} 一个SAS程序问题一个常见的问题
相关话题的讨论汇总
话题: sysevalf话题: thres话题: intercept话题: intp话题: le