SAS OperatorsIn the SAS, operators are the symbols, which areused to perform calculations like addition, multiplication, subtraction, division, comparison, etc. These symbols are inbuilt part of SAS programming language, so we can combine these symbols in a single expression to get the desired output. There are five types of operators in the SAS:
Arithmetic Operators:Arithmetic operators are used to perform mathematical calculations like addition, multiplication, subtraction, division, etc. The following table describes arithmetic operators with their operations.
Let's understand through an example, how we can use arithmetic operators in the SAS programming. Execute the above code in SAS studio: Output: As we can see in the output, all values have been calculated according to the arithmetic operators. Logical OperatorsLogical operators are used to evaluate the truth or false value of an expression.The result of logical operator is always Boolean value, i.e., 1 or 0. The following table describes logical operators with their operations.
Let's understand through an example, how we can use logical operators in SAS programming. Execute the above code in SAS studio: Output: As we can see in the output, all values are producing Boolean results according to the evaluation of logical operators. Comparison OperatorsComparison operators areused to compare the values on the basis of equality. The result of comparison operator is always Boolean value, i.e., 1(for true) or 0 (for false). The following table describes comparisonoperators with their operations.
Let's understand through an example, how we can use comparison operators in SAS programming. Execute the above code in SAS studio: Output: As we can see in the output, all values are producing Boolean results according to the evaluation of comparison operators. Minimum/Maximum OperatorsThese operators are used to compare the values of the variable across the row to return the maximum or minimum value from the list of values in the row.The following table describes Minimum/Maximum Operators with their operations.
Execute the above code in SAS studio: Output: As we can see in the output, minimum and maximum operators have returned the minimum and maximum values from the list of values in both rows. Concatenation OperatorConcatenation Operator is used to concatenate two or more string values. The following table describes the Concatenation Operator with its operation.
Execute the above code in SAS studio: Output: As we can see in the output, both string variables have been concatenated. Precedence Operator:Precedence Operator is a group of operators which indicates the order of evaluationin the case when multiple operators present in a complex expression.The following table describes Precedence Operatorswith their operations.
Next TopicNumeric Data Format
