Sample Topic 6: Numeric Functions

h

Arithmetic Operator

In SAS, there are five arithmetic operators. Below is the chart detailing each of the five operators:

Let's look at an example.

Data Test;
a = 3**2;
Run;

In this example, the value a is equal to 3 raised to the power of 2, which is 9.


Automatic Conversion

Sometimes, for whatever reason, you may choose to store a numeric value in a character variable.

When performing mathematical operations on such character variables, SAS will automatically convert the character values to numeric values.

Let's look at an example.

Data Retail;
cost = '20000';
total = .10 * cost;
run;

In this example, the COST variable contains a character value '20000'.

When multiplying the character value by 0.1, SAS will automatically convert the character value to a numeric value.

The total will be calculated as 2000.

✍️ Exam Tips

When performing a mathematical operation on a character variable, SAS will automatically convert the character values to numeric values before the operation.

💯 Sample Exam Question(s):
Question 1
Question 2

Get Solution