SAS中常用的运算符:
运算符 | SAS运算符 | 功能描述 | 示例 |
** |
| 幂 | y = a**2 |
+ |
| 正 | y = +(a+b) |
- |
| 负 | y = -(a+b) |
~ or ^ | NOT | 逻辑非 | if NOT age then put name |
>< | MIN | 最小值 | y = (a><b) |
<> | MAX | 最大值 | y = (a<>b) |
* |
| 乘法 | y = a*b |
/ |
| 除法 | y = a/b |
+ |
| 加法 | y = a+b |
- |
| 减法 | y = a-b |
|| !! ¦¦ |
| 字符串连接 | name = “zhang” || “shan” |
= | EQ | 等于(Equal) | if age = 25 if age EQ 25 |
^= or ~= | NE | 不等于(Not Equal) | if age ^= 26 if age NE 26 |
> | GT | 大于(Greater Than) | if age > 30 if age GT 30 |
< | LT | 小于(Less Than) | if age < 30 if age LT 30 |
>= | GE | 大于或等于(Greater Than or Equal) | if age >= 30 if age GE 30 |
<= | LE | 小于或等于(Less Than or Equal) | if age <= 30 if age LE 30 |
in | IN | 在列表中,用于选择多个值 | if age IN (25, 26, 30) |
& | AND | 逻辑与 | if sex=’M’ and age=25 then output |
| ! ¦ | OR | 逻辑或 | if set=’M’ or age=25 then output |