turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Why the values of numeric variable in two data set...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-27-2017 01:57 AM

Dear,

I ran proc compare on two datasets. The numeric variable values of two datasets are exactly same but not matching in proc compare. Any suggestions. Please help. Thanks.

The format and informat are same in both datasets.

I attached a proc compare report.

data base

AVAL

102.64285714

data compare

AVAL

102.64285714

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to knveraraju91

03-27-2017 02:02 AM

Look at the FUZZ option in PROC COMPARE

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to knveraraju91

03-27-2017 04:23 AM

Visibly equal data may not be technically equal. The way numbers are stored in SAS may create imprecisions far down from the decimal point that are not displayed when using typical number formats, but are detected by every comparison.

You can see this when compare displays the difference as1E-14 or something similar.

Either use the fuzz factor in compare (as @Reeza already suggested), or make use of the round() function when doing calculations that involve fractions.

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

Maxims of Maximally Efficient SAS Programmers

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to knveraraju91

03-27-2017 11:47 AM

And the practical affect of a difference of

0.000000000000013840

is going to be what on your process?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to knveraraju91

03-27-2017 12:07 PM

That is just one of the side effects of using binary computers to perform mathematicl operations.

Since there are many numbers that cannot be stored exactly in the IEEE floating point format you need to take that into consideration.

Here is a simple example that uses the fact the one tenth cannot be stored exactly.

```
data _null_;
one=1 ;
do _n_=1 to 10 ;
another_one + (1/10) ;
end;
diff = one - another_one ;
put (_all_) (= best32. / );
run;
```

one=1 another_one=1 diff=1.1102230246251E-16