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.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
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.

 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
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.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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