Hello
I want to round down by 500.
for example:
870 will be rounded to 500
1020 will be rounded to 1000
2580 will be rounded to 2500
2900 will be rounded to to 2500
what is the way to do it please?
data t;
input x;
cards;
870
1020
2580
2900
;
run;
data t2;
set t;
newvalue1 = round(x,500);
run;
I know this way but maybe have better solution
data t2;
set t;
newvalue1 = round(x,500);
if newvalue1>x then newvalue2=newvalue1-500;else newvalue2=newvalue1;
run;
How about
data t;
input x;
cards;
870
1020
2580
2900
;
data want;
set t;
y = x - mod(x, 500);
run;
As you see, the ROUND function doesn't round down, it rounds to the nearest 500. The fix is:
newvalue1 = round(x-250,500);
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.