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
- /
- Unable to get expected results while comparing Neg...

Topic Options

- 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
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-08-2018 11:22 AM

Hi Everyone,

I am comparing two Numeric Negative values in two columns within the same data set using Proc Compare and Method=Absolute. However, I am not getting some of the unmatched/expected records - for example values -2.75 and -2.74 do not come up in the output?

The columns/values have same precision, length and format as 5.2.

I have tried to search in our community for related topics and implemented Round() and Trunc() functions on the values before using them in Proc Compare function but no success. Can anyone please help as its urgent.

proc compare base = com_edc_cov Method=Absolute Criterion= 0.01 listall briefsummary ; var EDC_SDS; with SDS;

id SUBJECTNUMBERSTR Visit lbcat;

run;

Thanks so much !

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

02-08-2018 11:39 AM

Check the CRITERION would be my starting point. Setting it at 0.01 and not detecting 0.01 sets off flags in my head.

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

02-08-2018 11:40 AM

Note that

The columns/values have same precision, length and format as 5.2.

Does not mean that SAS sees the values as -2.75 when doing comparisons if the internal value is actually -2.7499356 or such. Format controls what is displayed not stored.

Consider:

data example; x = -2.744; y = -2.749; z = abs(y-x); put x= f5.2 y=f5.2 z= f6.4; run;

the value for the absolute difference is less than 0.01, your criterion setting so they would be considered equal by proc compare even though they will display a -2.74 and -2.75

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

Posted in reply to ballardw

02-08-2018 12:29 PM

Thank you so much for your help! Yes, I changed the Criterion to .001 but in that case I start getting values that are equal for eg

-2.09 and -2.09,

-2.28 and -2.28 etc

So, increasing Criterion is not helpful either.

I tried example below :-

z = abs(EDC_SDS - SDS);

put EDC_SDS = f5.2 SDS = f5.2 z = f6.4;

if z eq 0 then output;

I am getting whole dataset as the output since the z has values such as -

EDC_SDS=0.11 SDS=0.11 z=0.0049, EDC_SDS=-2.32 SDS=-2.32 z=0.002

I want output only if there is difference in EDC_SDS and SDS values.

Best !

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

02-08-2018 12:31 PM

Quick correction - Apologies :

The output is 0 records.

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

02-08-2018 04:55 PM

Do your comparison manually and make sure to round the numbers first to the level of precision you want compared.

PROC COMPARE is nice but it needs a lot of improvement in my experience and it's usually easier in the long run to roll my own.

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

02-08-2018 04:54 PM

PA8 wrote:

Thank you so much for your help! Yes, I changed the Criterion to .001 but in that case I start getting values that are equal for eg

-2.09 and -2.09,

-2.28 and -2.28 etc

There are times when you really want to round the values in a data step before use or comparisons.