Symbols
lists the symbols that you use to request the comparisons, operations, and
calculations.
Mnemonic Equivalent
lists alternate forms of the symbol. In some cases, such as when your keyboard does
not support special symbols, you should use the alternate form.
Definition
defines the symbol.
Example
provides an example of how to use the symbol or mnemonic equivalent in a SAS
expression.
Table 6.6 Order of Evaluation in Compound Expressions
Priority
Order of
Evaluation Symbols
Mnemonic
Equivalent Definition Example
Group I right to left **
exponentiation
*
y=a**2;
+
positive prefix
**
y=+(a*b);
-
negative prefix
***
z=-(a+b);
¬ ~ NOT
logical not
if not z
then put x;
>< MIN
minimum
††
x=(a><b);
<> MAX maximum
x=(a<>b);
Group II left to right * multiplication
c=a*b;
/ division
f=g/h;
Group III left to right + addition
c=a+b;
- subtraction
f=g-h;
Group IV left to right || ¦¦ !! concatenate character
values
†††
name= 'J'||'SMITH';
Group V
left to
right
‡‡
< LT less than
if x<y
then c=5;
<= LE less than or equal to
if x le y
then a=0;
= EQ equal to
if y eq (x+a)
then output;
¬= NE not equal to
if x ne z
then output;
>= GE greater than or equal to
if y>=a
then output;
SAS Operators in Expressions 109
Priority
Order of
Evaluation Symbols
Mnemonic
Equivalent Definition Example
> GT greater than
if z>a
then output;
IN equal to one of a list
if state in
('NY','NJ','PA')
then region='NE';
y = x in (1:10);
Group VI left to right & AND logical and
if a=b & c=d
then x=1;
Group VII left to right | ¦ ! OR
logical or
‡‡‡
if y=2 or x=3
then a=d;
*
Because Group I operators are evaluated from right to left, the expression x=2**3**4 is evaluated as x=(2**(3**4)).
**
The plus (+) sign can be either a prefix or arithmetic operator. A plus sign is a prefix operation ly when it appears at the beginning of an
expression or when it is immediately preceded by an open parenthesis or another operator.
***
The minus (−) sign can be either a prefix or arithmetic operator. A minus sign is a prefix operator only when it appears at the beginning
of an expression or when it is immediately preceded by an open parenthesis or another operator.
Depending on the characters available on your keyboard, the symbol can be the not sign (¬), tilde (~), or caret (^). The SAS system
option CHARCODE allows various other substitutions for unavailable special characters.
††
For example, the SAS System evaluates -3><-3 as -(3><-3), which is equal to -(-3), which equals +3. This is because Group I operators
are evaluated from right to left.
†††
Depending on the characters available on your keyboard, the symbol that you use as the concatenation operator can be a double vertical
bar (||), broken vertical bar (¦¦), or exclamation mark (!!).
Group V operators are comparison operators. The result of a comparison operation is 1 if the comparison is true and 0 if it is false.
Missing values are the lowest in any comparison operation. The symbols =< (less than or equal to) are also allowed for compatibility
with previous versions of the SAS System.When making character comparisons, you can use a colon (:) after any of the comparison
operators to compare only the first character or characters of the value. SAS truncates the longer value to the length of the shorter value
during the comparison. For example, if name=:'P' compares the value of the first character of NAME to the letter P.
‡‡
An exception to this rule occurs when two comparison operators surround a quantity. For example, the expression x<y<z is evaluated
as (x<y) and (y<z).
‡‡‡
Depending on the characters available on your keyboard, the symbol that you use for the logical or can be a single vertical bar (|),
broken vertical bar (¦), or exclamation mark (!). You can also use the mnemonic equivalent OR.
110 Chapter 6 Expressions
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.231.194