Published on :
Data Manipulation CREATION_INTERNE

Using SAS Numeric Functions

This code is also available in: Deutsch Español Français
Awaiting validation
The script first creates a dataset named 'Funct' with three numeric variables (number1, number2, number3) using the DATALINES statement. Then, a second DATA step reads this dataset and applies the CEIL, FLOOR, INT, and ROUND functions to these variables, storing the results in new variables. Finally, PROC PRINT is used to display the content of the resulting dataset, illustrating the effect of the functions.
Data Analysis

Type : CREATION_INTERNE


The 'Funct' dataset is created internally via DATALINES directly within the script.

1 Code Block
DATA STEP Data
Explanation :
This DATA step block creates a temporary dataset named 'Funct'. It defines three numeric variables (number1, number2, number3) and initializes them with fixed values provided via the DATALINES statement. This is the initial source of data for subsequent manipulations.
Copied!
1DATA Funct;
2INPUT number1
3number2
4number3
5;
6DATALINES;
711.85
832.5
95678.75
10;
2 Code Block
DATA STEP
Explanation :
This second DATA step reads the existing 'Funct' dataset. It creates new variables by applying numeric functions: CEIL (rounds up), FLOOR (rounds down), INT (integer part), and ROUND (rounds to the nearest integer by default) to the 'number1', 'number2', and 'number3' variables, respectively. The results are stored in the same 'Funct' dataset, potentially overwriting the old dataset if not specified differently.
Copied!
1DATA Funct;
2SET Funct;
3Ceil1 = ceil(number1);
4Floor1 = floor(number1);
5int = int(number2);
6round = round(number3);
7RUN;
3 Code Block
PROC PRINT
Explanation :
This block uses the PROC PRINT procedure to display the final content of the 'Funct' dataset. The title 'Inbuilt functions' is added to the output report, allowing visualization of the original values and the results of the applied numeric functions.
Copied!
1 
2PROC PRINT
3DATA = Funct;
4title "Inbuilt functions";
5RUN;
6 
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.