1

I have one number which I need to find the ceiling and the floor value of (203,400) in order to use this number to create a weighted average. From this number I want: 200,000 and 210,000 so the code I was using that doesn't work is:

S1CovA_ceil = ceil(S1CovA,10000);
S1CovA_floor = floor(S1CovA,10000);

When I run this program, I get these errors: ERROR 72-185: The CEIL function call has too many arguments. ERROR 72-185: The FLOOR function call has too many arguments.

Does anybody know a way around this or different SAS code I could use?

Sarah Reinke
  • 57
  • 3
  • 9

3 Answers3

2

CEIL and FLOOR only remove decimals - specifically rounding to integer value. If you want it rounded to (above/below) multiple of 10,000, you have to do it a bit more complicatedly:

S1CovA_ceil = ceil(s1covA/10000)*10000;

And the same for floor. Basically you have to divide it by the desired rounding level, round the rest with ceil/floor, and then multiply back.

Unfortunately, as far as I'm aware, SAS doesn't allow rounding in a particular direction except for straight integer rounding.

Joe
  • 62,789
  • 6
  • 49
  • 67
1

You can also use the round() function...

%LET ROUNDTO = 10000 ;
data xyz ;
  S1CovA_ceil  = round(S1CovA+(&ROUNDTO / 2),&ROUNDTO) ;
  S1CovA_floor = round(S1CovA-(&ROUNDTO / 2),&ROUNDTO) ;
run ;
Chris J
  • 7,549
  • 2
  • 25
  • 25
0

Try

    S1CovA_ceil = ceil(S1CovA/10000)*10000;  
    S1CovA_floor = floor(S1CovA/10000)*10000;  
Michael Kersten
  • 427
  • 2
  • 11