Published on :
ETL CREATION_INTERNE

Data Filtering and Display with DATA STEP and PROC PRINT

This code is also available in: Deutsch Español Français
Awaiting validation
This SAS© script illustrates data creation and processing in two main steps. First, a DATA STEP block is used to read raw data directly embedded in the script (DATALINES) and build the dataset named 'prob12_18'. The variables DATE, GENDER, AGE, and SCORE are defined with their appropriate formats and informats. A conditional statement 'if GENDER = 'F';' filters the observations, keeping only those where the GENDER variable has the value 'F' (Female). Then, the PROC PRINT procedure is called to display the content of the 'prob12_18' dataset, applying the title 'Problem 12.18' to the output. The script is designed to be executable in a SAS© Viya 4 or SAS© Studio environment.
Data Analysis

Type : CREATION_INTERNE


The data used to create the 'prob12_18' dataset is directly included in the SAS script via the DATALINES statement, making it an internal and integrated data source within the code.

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block is responsible for creating the 'prob12_18' dataset. The `input` statement reads the raw data provided in the `datalines` section, specifying informats for each variable (e.g., `mmddyy10.` for DATE, `$11` for GENDER, numeric positions for AGE and SCORE). The `format` statement applies a display format to the DATE variable. The `if GENDER = 'F';` statement acts as an implicit filter, retaining in the final dataset only observations where the GENDER variable is equal to 'F'.
Copied!
1DATA prob12_18;
2 INPUT DATE mmddyy10. GENDER $11 AGE 12-13 SCORE 14-16;
3 FORMAT DATE mmddyy10.;
4 IF GENDER = 'F';
5 
6DATALINES;
704/04/2004M15 90
805/12/2004F16 95
907/23/2004M18 88
1001/20/2004F17100
11;
2 Code Block
PROC PRINT
Explanation :
This block uses the PROC PRINT procedure to generate a tabular report displaying the content of the previously created 'prob12_18' dataset. The `title` statement sets the title 'Problem 12.18' which will appear above the report.
Copied!
1PROC PRINT;
2 title 'Problem 12.18';
3RUN;
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.