# How to Calculate Absolute Values in SAS (With Example)

You can use the ABS function in SAS to return the absolute value of a given number.

This function uses the following basic syntax:

ABS(argument)

where:

• argument: A numeric value

The following example shows how to use this function to calculate absolute values in practice.

## Example: How to Calculate Absolute Values in SAS

Suppose we have the following dataset in SAS:

```/*create dataset*/
data original_data;
input values;
datalines;
100
-40
0
50
23.5
-1.44
-0.54
12
18
-22
;
run;

/*view dataset*/
proc print data=original_data;
``` We can use the ABS function to calculate the absolute value of each numeric value in the values column:

```/*create new dataset*/
data new_data;
set original_data;
abs_values = abs(values);
run;

/*view new dataset*/
proc print data=new_data;
``` Notice that the new column called abs_values contains the absolute value of each numeric value from the values column.

For example:

• The absolute value of 100.00 is 100.00.
• The absolute value of -40.00 is 40.00.
• The absolute value of 0.00 is 0.00.

And so on.