DATA Step, Macro, Functions and more

3 significant digit rounding of a number

Reply
Occasional Contributor Uli
Occasional Contributor
Posts: 8

3 significant digit rounding of a number

Dear All,

Please help me out of the following issue,

Input -------------------------------------output
2 ------------------------ 2.00
22 ------------------------ 22.0
100 ------------------------ 100
250.678 ------------------------ 250.678
250.6786 ------------------------ 250.679
0.0067 ------------------------ 0.0067
0.00006789------------------------ 0.00000679
0.7567 ------------------------------- 0.757


The number needs to be round to 3 significant digits. user defined function or any other solution would be great help for me.

Thanks In Advance

Best Regards
Super Contributor
Super Contributor
Posts: 365

Re: 3 significant digit rounding of a number

Hello Uli,

It is a solution:
[pre]
data i;
input a;
format a E9.3;
if a LT 100 then r=INPUT(PUT(a,E9.3),15.8);
else r=INPUT(PUT(a,15.3),15.3);
datalines;
2
22
100
250.678
250.6786
0.0067
0.00006789
0.7567
run;
[/pre]
Sincerely,
SPR
Ask a Question
Discussion stats
  • 1 reply
  • 1285 views
  • 0 likes
  • 2 in conversation