Search the site...

SASCRUNCH TRAINING
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
Sentry Page Protection
Please Wait...
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.
Picture

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;
Picture

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.
Next

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.

Already a member? Go to member's area.