turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Ceil and floor calculations at [-1,1]

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-04-2018 02:50 AM

I am calculating a fraction based on the payments made in four years and I wish to put a cap on my fraction such that it can only be between -1 and 1. Subsequently I'd like to make the following fractions 0 if the cap is maxxed out - an example would be:

```
data want;
input payment1 payment2 payment3 payment4 fraction1 fraction2 fraction3;
datalines;
100 25 25 25 0.25 0.25 0.25
150 50 50 50 0.33 0.33 0.33
50 10 10 10 0.2 0.2 0.2
10 50 60 70 1 0 0
;
run;
```

I've been looking at the ceiling function with the following code

```
data want2;
set want;
array fraction(3) fraction1 - fraction3;
array payment(4) payment1 - payment4;
do i = 2 to 4;
fraction(i-1) = payment(i)/payment(1);
end;
run;
data want3;
set want2;
array fraction(3) fraction1 - fraction3;
array fract(3) fract1-fract3;
do i = 1 to 3;
fract = ceil (fraction,1);
end;
drop i;
run;
```

but I am getting this error

ERROR 72-185: The CEIL function call has too many arguments.

So in all i'm looking for a way to calculate the fraction of the payments and then make a ceiling at one, then once the ceiling is hit, the subsequent fractions must be zero (which could be done I suppose by just doing an IF-THEN)

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to 89974114

04-04-2018 03:56 AM

The ceil function rounds up that is it.

I would suggest to just use an if-statement.

I would suggest to just use an if-statement.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to 89974114

04-04-2018 06:50 AM

Switching from CEIL to MIN seems like it would do what you are asking.