Hello
I want to round the number by 500 (up or down)
for example
17524.5 will be converted to 18000
25475.37 will be converted to 25000
6475.3 will be converted to 6000
what is the way to do it please?
SAS Help Center: ROUND Function
I think it is easy for you .
data have;
input have;
want=1000*round(have/1000);
cards;
17524.5
25475.37
6475.3
;
proc print;run;
@Ronein Like below:
/* %let round_to=500; */
%let round_to=1000;
data test;
do val=1,249.9,250,250.1,499.1,500,500.1,749.9,750,750.1,17524.5,25475.37,6475.3;
round_val=round(val,&round_to);
output;
end;
run;
proc print data=test;
run;
Above updated after @Kurt_Bremser 's remark
Given your examples, you want to round by 1000, not by 500.
@Ronein wrote:
Hello
I want to round the number by 500 (up or down)
for example
17524.5 will be converted to 18000
25475.37 will be converted to 25000
6475.3 will be converted to 6000
what is the way to do it please?
Exactly.
data have;
input x expect;
cards;
17524.5 18000
25475.37 25000
6475.3 6000
;
data want;
set have;
round1000=round(x,1000);
round500=round(x,500);
run;
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.
Ready to level-up your skills? Choose your own adventure.