DATA Step, Macro, Functions and more

converting -0.00 to 0.00

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

converting -0.00 to 0.00

Hello,

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

With best32. I have -0.00

Thank you

Cordially


Accepted Solutions
Solution
‎12-15-2017 03:10 PM
SAS Super FREQ
Posts: 508

Re: converting -0.00 to 0.00

Posted in reply to mansour_ibrahim

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


All Replies
Community Manager
Posts: 3,462

Re: converting -0.00 to 0.00

Posted in reply to mansour_ibrahim

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.

Solution
‎12-15-2017 03:10 PM
SAS Super FREQ
Posts: 508

Re: converting -0.00 to 0.00

Posted in reply to mansour_ibrahim

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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 206 views
  • 4 likes
  • 3 in conversation