Sas是否提供了chain
-表达式的机制?SAS:IF语句中的表达式
确实Sas提供In
的机制 - 条款?
简单的例子:
a = '09MAY2010'd;
b = '17MAY2010'd;
if (a<=c<=b) then do; /*code*/ end;
if (c in (a:b)) then do; /*code*/ end;
也许,如果/,语句什么好的技巧?
您的建议和建议,请。
谢谢!
Sas是否提供了chain
-表达式的机制?SAS:IF语句中的表达式
确实Sas提供In
的机制 - 条款?
简单的例子:
a = '09MAY2010'd;
b = '17MAY2010'd;
if (a<=c<=b) then do; /*code*/ end;
if (c in (a:b)) then do; /*code*/ end;
也许,如果/,语句什么好的技巧?
您的建议和建议,请。
谢谢!
你的榜样,改了一下:
data _null_;
a = '09MAY2010'd;
b = '17MAY2010'd;
c = '17MAY2010'd;
if (a<=c<=b) then do;
putlog "a<=c<=b";
end;
select (c);
when (a, b) putlog "in a, b";
when ('17MAY2010'd) putlog "'17MAY2010'd";/* not used, only first match is executed */
otherwise;
end;
run;
与IF或使用运营商WHERE子句需要在列表中的常量。
不错,但第二个呢? ('c in(a:b)')我是对的吗,我不能使用带有范围的IF语句,只有IF的每个边界是常量? – gaussblurinc
不确定你的意思:if(a <= c <= b)有效地引用由变量定义的范围,而不是常量。 – vasja
no-no,我的意思是'(c in(a:b))'作为一个范围。链比较工作。 – gaussblurinc
除了IN
运营商,只接受paranthesis内是恒定值,也有一个(无证)IN
功能,这可以通过使用变量可以使用,所以不是if c in(a,b)
可以使用if in(c,a,b)
这也将工作当和b是变量。
另一种可能性是使用WHICHN
或WHICHC
功能,其具有相同的语法,并且其返回0
(FALSE
)当未找到匹配,否则(第一)匹配的数目。
谢谢!我已经清除了我的错误知识 – gaussblurinc
如果你知道了,你应该发布并回答你的问题。 – Banjer