BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Angel_Saenz
Quartz | Level 8
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
ballardw
Super User

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.

 

View solution in original post

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

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
ballardw
Super User

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.

 

Tom
Super User Tom
Super User

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 734 views
  • 6 likes
  • 4 in conversation