Sasは-式のメカニズムを提供しchain
ますか?
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ステートメントの良いテクニックはありますか?
あなたの提案やアドバイスをお願いします。
ありがとう!
Sasは-式のメカニズムを提供しchain
ますか?
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ステートメントの良いテクニックはありますか?
あなたの提案やアドバイスをお願いします。
ありがとう!
あなたの例は、少し変更されました:
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演算子には、リスト内の定数が必要です。
IN
パランテシス内の定数値のみを受け入れる演算子とは別に、IN
変数で使用できる(文書化されていない)関数もあるため、aとbが変数の場合にも機能if c in(a,b)
するを使用できます。if in(c,a,b)
もう1つの可能性は、同じ構文を持ち、一致が見つからない場合は( )を返し、それ以外の場合は(最初の)一致の数を返すWHICHN
または関数を使用することです。WHICHC
0
FALSE