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
Rhodochrosite | Level 12

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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
WarrenKuhfeld
Rhodochrosite | Level 12

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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