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);
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.