🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-06-2018 06:49 PM
(1081 views)
Is there a function to round tens down?
example
data
111 1499 15251
data I want
100 1400 15200
but do not using /100 and after *100 I want if exits a function that simplifies it please
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Slightly different since the request is to always round down.
data have; input value1 value2 value3; newval1=100* floor(value1/100); newval2=100* floor(value2/100); newval3=100* floor(value3/100);; cards; 111 1499 15251 ;
unfortunately the FLOOR and CEIL functions do not have the round off precision value parameter that ROUND does.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
if we use round as below we get
100 1500 15300
data have;
input value1 value2 value3;
newval1=round(value1,100);
newval2=round(value2,100);
newval3=round(value3,100);
cards;
111 1499 15251
;
Thanks,
Jag
Jag
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Slightly different since the request is to always round down.
data have; input value1 value2 value3; newval1=100* floor(value1/100); newval2=100* floor(value2/100); newval3=100* floor(value3/100);; cards; 111 1499 15251 ;
unfortunately the FLOOR and CEIL functions do not have the round off precision value parameter that ROUND does.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
No. Here are two algorithms. You could use PROC FCMP to make your own function, but it is probably NOT worth the effort.
data test;
input have @@;
test1=round(have,100);
test2=100*int(have/100);
test3=have-mod(have,100);
cards;
111 1499 15251
;
Obs have test1 test2 test3 1 111 100 100 100 2 1499 1500 1400 1400 3 15251 15300 15200 15200