BookmarkSubscribeRSS Feed
SireeshaKarthik
Calcite | Level 5
Hi, the results for a proc compare , some numeric values are showing extra three decimal points by default. How I can ignore the extra decimals
5 REPLIES 5
Quentin
Super User

Can you add a little example of what you mean?  Do you mean you have data where the only difference is in the third decimal place, like:

 

data a ;
  x=1.501 ;
run ;

data b ;
 x=1.502 ;
run ;

proc compare base=a compare=b ;
run ;

And you want PROC COMPARE  to report that those two values are equal? If that's what you mean, look into the CRITERION option.

SireeshaKarthik
Calcite | Level 5
Thanks for the quick response.

For example ×=200 , b=220

While comparing , it shows like below
X B diff
200.000 220.000 -20.000

How to ignore the last decimal points, need to see like below

X B diff
200 220 -20


Quentin
Super User

You can add a FORMAT statement:

 

data a ;
  x=200 ;
run ;

data b ;
 x=220 ;
run ;

proc compare base=a compare=b ;
  format x 8. ;
run ;

That doesn't impact the comparison, but will show X formatted with no decimal places:

          ||       Base    Compare
      Obs ||          x          x      Diff.     % Diff
________  ||  _________  _________  _________  _________
          ||
       1  ||        200        220    20.0000    10.0000
_________________________________________________________

The difference still shows decimal places.  If you don't want that, you might be able to edit a table template or something like that.  I don't see a MAXDEC option or similar for PROC COMPARE.

 

SireeshaKarthik
Calcite | Level 5
Yes. We can use maxdec for proc report, the variable has already format 8.
Quentin
Super User

Apparently PROC COMPARE does not actually use a table template, so I'm not sure you can fully customize this.

 

See this paper by the great Jane Eslinger, which has a section on COMPARE

https://www.pharmasug.org/proceedings/2019/BP/PharmaSUG-2019-BP-039.pdf

 

Jane suggests for custom output from PROC COMPARE, you may want to output the results to a dataset, then use PROC REPORT or whatever to display they results.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1798 views
  • 0 likes
  • 2 in conversation