Sas是否提供chain-expressions机制?
Sas是否提供In-clause机制?
简单的例子:
a = '09MAY2010'd;
b = '17MAY2010'd;
if (a<=c<=b) then do; /*code*/ end;
if (c in (a:b)) then do; /*code*/ end;也许if/where语句有什么好的技巧?
请给我您的建议和建议。
谢谢!
发布于 2012-07-03 20:59:21
您的示例稍有更改:
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子句一起使用的IN运算符需要列表中的常量。
发布于 2017-12-08 22:07:41
除了IN操作符,它只接受括号内的常量值,还有一个(未记录的) IN函数,它可以与变量一起使用,因此您可以使用if in(c,a,b)而不是if c in(a,b),当a和b是变量时,它也可以工作。
另一种可能是使用WHICHN或WHICHC函数,这两个函数具有相同的语法,如果没有找到匹配,则返回0 (FALSE),否则返回(第一个)匹配的编号。
https://stackoverflow.com/questions/11308724
复制相似问题