Published on :
Data Management CREATION_INTERNE

Handling Missing Values in Arithmetic Calculations

This code is also available in: Deutsch Español Français
Awaiting validation
This script creates a dataset named 'cholesterol' to demonstrate the standard behavior of SAS© when performing arithmetic calculations involving missing values. If one of the variables (Ldl, Hdl, or Vldl) is missing, the resulting sum (Total1) will also be missing.
Data Analysis

Type : CREATION_INTERNE


Data is generated directly within the script via the DATALINES statement.

1 Code Block
DATA STEP Data
Explanation :
DATA step creating the 'cholesterol' table. The 'Total1' variable is calculated by adding Ldl, Hdl, and Vldl. Observation #2 contains a dot (.) for Vldl, which will result in a missing value for Total1 on this line.
Copied!
1DATA cholesterol;
2 INPUT ID Ldl Hdl Vldl;
3 Total1 = Ldl + Hdl + Vldl;
4 DATALINES;
51 160 50 20
62 150 55 .
73 120 40 30
84 140 50 25
9;
10RUN;
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.