# Issue

I have a problem with decimal places in my SAS-variables.

I have two numeric variables which I want to compare in SAS.
They are both formatted with `numx10.1`

and one of the variables is calculated like this:

```
avg(delay)/30.44 as delay_months format=numx10.1
```

I want to compare the two values in a datastep using

```
where var1^=delay_months ;
```

But even thought both variables have the same value for example. 4,1, SAS still shows this observation in the datastep with the `where-statement`

.
I guess it is because of the decimals in the `delay_months`

variable.

How can I get SAS to forget the decimal places and only focus on the number I see - for example 4,1?

# Solution

Format does not change the value - it is only the way SAS represents it to you. One suggestion could be rounding during comparison (or when you create the variables)

```
where round(var1, 0.1) ^= round(delay_months, 0.1);
```

SAS uses floating-point representation for numeric values. Because of that sometimes what you see is not what it is. More about that in SAS documentation

Answered By - Grinvydas Kareiva Answer Checked By - Clifford M. (PHPFixing Volunteer)

## 0 Comments:

## Post a Comment

Note: Only a member of this blog may post a comment.