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 !
Check the CRITERION would be my starting point. Setting it at 0.01 and not detecting 0.01 sets off flags in my head.
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
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 !
Quick correction - Apologies :
The output is 0 records.
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.
@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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.