Chapter 6
Expressions
Definitions for SAS Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Examples of SAS Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
SAS Constants in Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Character Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Using Quotation Marks with Character Constants . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Comparing Character Constants and Character Variables . . . . . . . . . . . . . . . . . . . . 94
Character Constants Expressed in Hexadecimal Notation . . . . . . . . . . . . . . . . . . . . 94
Numeric Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Numeric Constants Expressed in Standard Notation . . . . . . . . . . . . . . . . . . . . . . . . 94
Numeric Constants Expressed in Scientific Notation . . . . . . . . . . . . . . . . . . . . . . . . 95
Numeric Constants Expressed in Hexadecimal Notation . . . . . . . . . . . . . . . . . . . . . 95
Date, Time, and Datetime Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Bit Testing Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Avoiding a Common Error with Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
SAS Variables in Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Automatic Numeric-Character Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
SAS Functions in Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
SAS Operators in Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
The IN Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Numeric Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
The IN Operator in Numeric Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Character Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
The IN Operator in Character Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Logical (Boolean) Operators and Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
The AND Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
The OR Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
The NOT Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Boolean Numeric Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
The MIN and MAX Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
The Concatenation Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Order of Evaluation in Compound Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
91

Get SAS 9.4 Language Reference, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.