Published on :
ETL, Reporting CREATION_INTERNE

Using Functions and Printing Data

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins with a DATA step named 'answer'. It calculates the value of a variable 'x' using a combination of the MIN, SUM, and N functions. The SUM(1,2,3) function returns 6. The operation 56/8 returns 7. The N(8) function returns 1 (it counts the number of non-missing values). The MIN function takes the minimum of these three results (MIN(6, 7, 1)), meaning that the variable 'x' will be assigned the value 1. Then, a PROC PRINT step is used to display the content of the 'answer' dataset, which will contain one observation with variable x=1, confirming the calculation result.
Data Analysis

Type : CREATION_INTERNE


The 'answer' dataset is entirely created within the DATA step from literal values and the results of SAS functions. It does not depend on any external data source or any pre-existing SAS library such as SASHELP.

1 Code Block
DATA STEP Data
Explanation :
This DATA block creates a dataset named 'answer'. A new variable 'x' is calculated. Its value is the minimum of the following results: the sum of the numbers 1, 2, and 3 (which is 6), the result of the division 56/8 (which is 7), and the count of non-missing values in the parenthesis for N(8) (which is 1). Therefore, 'x' will be equal to 1.
Copied!
1 
2DATA answer;
3x = MIN(SUM(1,2,3), 56/8, N(8));
4RUN;
5 
2 Code Block
PROC PRINT
Explanation :
This block uses the PROC PRINT procedure to formally display the content of the 'answer' dataset created in the previous DATA step. This allows viewing the variable 'x' and its final value.
Copied!
1PROC PRINT DATA=answer;
2RUN;
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.