BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mansour_ibrahim
Obsidian | Level 7

Hello,

I want to get a 0.00 from this value -1.42109E-14.

With best32. I have -0.00

Thank you

Cordially

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenKuhfeld
Ammonite | Level 13

This would be one way to display values near zero as zero.  No doubt others will chime in with other ways.

 

proc format;
   value myfmt -1e-12 - 1e-12 = '                            0.00';
run;

data x;
   do i = -1 to 1 by 0.1;
      j = i;
      output;
   end;
   format i best32. j myfmt32.;
 run;
   
proc print; run;

View solution in original post

2 REPLIES 2
ChrisHemedinger
Community Manager

This is a nuance of floating point representation.  See What's the difference between 0 and -0?

 

You might consider using the ROUND function, or multiplying the value by 1.0 might do the trick.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
WarrenKuhfeld
Ammonite | Level 13

This would be one way to display values near zero as zero.  No doubt others will chime in with other ways.

 

proc format;
   value myfmt -1e-12 - 1e-12 = '                            0.00';
run;

data x;
   do i = -1 to 1 by 0.1;
      j = i;
      output;
   end;
   format i best32. j myfmt32.;
 run;
   
proc print; run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 2 replies
  • 1747 views
  • 4 likes
  • 3 in conversation