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

Hi,

  I am trying to round off the value upto its 8 decimal places I tried following functions and getting results against it but it is not as expect it to be

e.g. value 0.00932304

round function=0

ceil=1

floor=0

int=0

what shall I try so that I can get some result other than these?

I am trying it for column.

 

Thank You 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You might also consider just associating an appropriate display format:

 

Proc print data=your data;

   var yourvariable;

   format yourvariable f16.8;

run.

 

will display the value rounded to 8 decimal places and does not require an additional pass through your data to modify the varible(s).

View solution in original post

6 REPLIES 6
Loko
Barite | Level 11

Hello,

 

Could you post the code you've tried ?

 

This one works fine:

data want;
x=0.009323049;
y=round(x,.00000001);
run;
nishukhawale
Obsidian | Level 7
thank you for your reply however I got the output
by using following function
Var_new= round(var, 10**-dp)
nishukhawale
Obsidian | Level 7
yours also gives the same output
ballardw
Super User

You might also consider just associating an appropriate display format:

 

Proc print data=your data;

   var yourvariable;

   format yourvariable f16.8;

run.

 

will display the value rounded to 8 decimal places and does not require an additional pass through your data to modify the varible(s).

nishukhawale
Obsidian | Level 7
actually I would like make the process automated and Proc print will not work for me. but thank you very much for your reply and good news is I got the answer for that Var_new= round(var, 10**-dp)
ballardw
Super User

ANY SAS Procedure will accept a format and you can permanently associate the format in either a data step or use Proc Datasets to modify the format for existing variables in existing data sets.

 

Proc Print was just an example of how to use in a procedure.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 6 replies
  • 3572 views
  • 2 likes
  • 3 in conversation