Sentry Page Protection
SAS Functions [6-14]
FLOOR Function
You can use the FLOOR function to round down numeric values.
Let's take a look at the NUMBERS data set below.
The NUMBERS data set above, again, contains a list of random numbers.
[Reminder: To see the NUMBERS data set on SAS Studio, run the code in the yellow box above]
Now, let's take a look at an example of the FLOOR function.
Example
Data Numbers2;
Set Numbers;
Randno2 = floor(Randno);
Run;
The FLOOR function rounds down the values to the nearest integer.
Note: unlike the ROUND function, the FLOOR function takes on only 1 parameter. There is no option to round down the values by any rounding factor.
Exercise
Take a look at the NUMBERS data set.
Write a SAS program to round down the RANDNO variable to 1 decimal place.
E.g. 2.68 --> 2.6
Create any data set or variables if necessary.
Take a look at the NUMBERS data set.
Write a SAS program to round down the RANDNO variable to 1 decimal place.
E.g. 2.68 --> 2.6
Create any data set or variables if necessary.
Need some help?
HINT:
There is no rounding factor for the FLOOR function. A simple mathematical tweak is needed to round down the values to 1 decimal place.
SOLUTION:
Data Numbers2;
Set Numbers;
Randno2 = Randno*10;
Randno3 = Floor(Randno2) / 10;
Run;
Fill out my online form.