BookmarkSubscribeRSS Feed
omega1983
Calcite | Level 5

data test;
if total = -0 then R=0;

run;

This did not convert -0 to 0;

I tried this also

data test;

if total = 0 then R = abs(val0);

run;

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Do you really have values that are –0?? I have never seen them. Why bother converting them, anyway?

But your code is off the mark.

How about this untested code:

data test;

     set test;

     if total= -0 then total=0;

run;

--
Paige Miller
data_null__
Jade | Level 19

Paige Miller wrote:

Do you really have values that are –0?? I have never seen them. Why bother converting them, anyway?

But your code is off the mark.

How about this untested code:

data test;

     set test;

     if total= -0 then total=0;

run;

It's has to do with w.d format.  I don't know if it is intentional or not but very small negative print as -0.

17         data _null_;
18            do x = -3e-16, round(x,1e-15);;
19               put 'NOTE: ' x= x=10.1 x=10.2 x=10.3;
20               end;
21            run;

NOTE:
x=-3E-16 x=-0.0 x=-0.00 x=-0.000
NOTE: x=
0 x=0.0 x=0.00 x=0.000
Reeza
Super User

It's showing as -0, but is probably -0.000009 or something like that.

Try a round function or a floor or ceiling instead depending on what will work based on your other data points.

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