SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
IGD
Calcite | Level 5 IGD
Calcite | Level 5

Hi everyone,

I cannot make sense of this output.

 

c=(abs(-2.271120)*100000);
d=floor(c);

 

output:

c=227112

d=227111

 

I expected to see d=227112 why i am getting this result?

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @IGD and welcome to the SAS Support Communities!

 

Use the ROUND function to avoid the issue

c=round(abs(-2.271120)*100000,1e-8);

and see the 2015 thread ceil function bug? for explanations.

View solution in original post

4 REPLIES 4
FreelanceReinh
Jade | Level 19

Hi @IGD and welcome to the SAS Support Communities!

 

Use the ROUND function to avoid the issue

c=round(abs(-2.271120)*100000,1e-8);

and see the 2015 thread ceil function bug? for explanations.

IGD
Calcite | Level 5 IGD
Calcite | Level 5

this worked thank you very much

acordes
Rhodochrosite | Level 12

I suppose it has to do with the floating points. 

Try 

data _null_;

format b c d best12.;

b=abs(-2.271120);

c=(abs(-2.271120)*100000);
d=floor(c);

put b= c= d= ;

run;

 

IGD
Calcite | Level 5 IGD
Calcite | Level 5

it is giving me

b=2.27112 c=227112 d=227111 so it did not work but thank you for replying

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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