Study guide

7.5 Handling Missing Values & Preventing Calculation Propagations

SAS Certified Specialist: Base Programming Using SAS 9.4 A00-231

Track your progress as you read

Finished sections get a check mark.

1 Chapter 1: SAS Base Programming Exam Overview

1.1 A00-231 Exam Format, Scoring & Test-Day Logistics 1.2 Official Content Areas, Weights & Study Plan

2 Chapter 2: Accessing & Creating SAS Data Structures

2.1 SAS Environment, Syntax Rules, & Data Step Basics 2.2 SAS Data Libraries & the LIBNAME Statement 2.3 Investigating Libraries with PROC CONTENTS & PROC DATASETS 2.4 Importing Delimited & Excel Data with PROC IMPORT 2.5 Raw Data Ingestion with INFILE and INPUT Statements

3 Chapter 3: Managing & Combining SAS Data Sets

3.1 Reading SAS Data Sets with the SET Statement 3.2 Combining Data Sets: Concatenating & Interleaving 3.3 Match-Merging with BY Statements & FIRST./LAST. Processing 3.4 Controlling Data Output & Variable Selection (KEEP, DROP, RENAME, OBS=)

4 Chapter 4: Data Transformation & Conditional Logic

4.1 Creating & Modifying Variables with Assignment Statements 4.2 Modifying Variable Attributes with LENGTH, LABEL, FORMAT & RENAME= 4.3 Conditional Processing: IF-THEN/ELSE Statements & WHERE Subsetting 4.4 Accumulating Totals & Subtotals (RETAIN & Sum Statement) 4.5 Processing Data Iteratively with DO Loops

5 Chapter 5: SAS Functions & Data Type Conversions

5.1 Character Functions for String Manipulation 5.2 Numeric & Mathematical Functions 5.3 Working with SAS Dates, Times, & Intervals 5.4 Reading & Displaying Dates with Informats and Formats 5.5 Explicit & Implicit Data Type Conversions (INPUT & PUT)

6 Chapter 6: Restructuring Data & Program Maintenance

6.1 SAS Array Processing for Multi-Variable Transformations 6.2 Sorting Data Sets with PROC SORT 6.3 Restructuring Data Sets with PROC TRANSPOSE 6.4 Creating & Applying Custom Formats with PROC FORMAT 6.5 Simplifying Programs with Macro Variables (%LET)

7 Chapter 7: Error Handling & Debugging SAS Programs

7.1 SAS Log Analysis & Diagnostic Messages 7.2 Syntax vs. Logic Errors & Phasing 7.3 Debugging Techniques with _ERROR_, _N_, & PUT Statements 7.4 Identifying Logic Errors with the PUTLOG Statement 7.5 Handling Missing Values & Preventing Calculation Propagations

8 Chapter 8: Summary & Detail Data Reporting

8.1 Detail Reporting with PROC PRINT 8.2 Descriptive Statistics with PROC MEANS & PROC SUMMARY 8.3 Frequency & Categorical Analysis with PROC FREQ 8.4 Screening Extreme & Missing Values with PROC UNIVARIATE 8.5 Custom Tabular Reports with PROC REPORT & PROC TABULATE

9 Chapter 9: ODS Output Delivery & Data Export

9.1 Output Delivery System (ODS) Architecture Basics 9.2 Generating PDF, HTML, & RTF Output Destinations 9.3 Exporting Reports to Excel with ODS EXCEL & XLSX 9.4 Generating CSV, PowerPoint & Other ODS Destinations 9.5 Customizing ODS Titles, Footnotes, & Global Options 9.6 Exporting SAS Data Sets with PROC EXPORT & the XLSX Engine

7.5 Handling Missing Values & Preventing Calculation Propagations

Key Takeaways Explain This Topic AI

Numeric missing values are represented internally by a single period (.) or special missing letters (.A-.Z, ._), while character missing values are represented by a blank space (' ').

In SAS sorting and logical comparisons, numeric missing values evaluate as the smallest possible numbers (smaller than all negative numbers).

Standard arithmetic operators (+, -, *, /) propagate missing values: if any operand is missing, the resulting evaluation is set to missing (.).

SAS sample statistic functions (e.g., SUM, MEAN, MIN) automatically ignore missing values, evaluating over non-missing arguments only.

To prevent logical errors when subsetting numeric variables, filtering expressions must account for missing values (e.g., WHERE 0 < Age < 21 instead of WHERE Age < 21).

Last updated: August 2026

7.5 Handling Missing Values & Preventing Calculation Propagations

Missing values are a fundamental reality of data processing. A missing value represents the absence of data for a specific variable in an observation. In Base SAS programming, missing values behave in very specific ways during arithmetic calculations, conditional evaluations, and sorting operations. Misunderstanding missing value propagation is one of the most common causes of logic errors on the Base SAS certification exam.

1. Representation of Missing Values in SAS

SAS distinguishes between numeric and character missing values in internal memory and dataset storage:

  • Variable Type Visual Representation Internal Memory Value
  • Numeric Single period ( . ) Smallest possible numeric value ( − ∞ -\infty − ∞ )
  • Character Single blank space ( ' ' ) ASCII / Unicode space character
  • Special Numeric Missing Values ( .A through .Z and ._ )

In addition to the standard period ( . ), SAS supports 27 special numeric missing values : .A through .Z and ._ (underscore). These are used in survey research, clinical trials, and data warehousing to encode specific reasons why data is missing (e.g., .N = Not Applicable, .R = Refused to Answer).

When sorted, special numeric missing values follow a strict hierarchy:

  • ._ < . < .A < .B < ... < .Z < Negative Numbers < 0 < Positive Numbers
  • 2. Missing Values in Logical Comparisons & Subsetting

Because numeric missing values ( . ) evaluate as smaller than all negative numbers , failing to account for missing values in IF or WHERE clauses leads to critical logic errors. /* CRITICAL EXAM PITFALL: Missing values in comparison logic */

  • data work.youth;
  • set work.patients;
  • if age < 18 then status = 'Minor'; /* LOGIC ERROR! */
  • run;

Why is this a logic error? If age is missing ( . ), SAS evaluates . < 18 as TRUE because . is smaller than 18. Consequently, all patients with missing ages are incorrectly classified as 'Minor' !

Safe Subsetting Coding Patterns

To prevent missing values from satisfying numeric comparison filters, use explicit missing value checks or range conditions: /* Safe Pattern 1: Using the MISSING() function */

  • data work.youth_correct;
  • set work.patients;
  • if not missing(age) and age < 18 then status = 'Minor';
  • run;
  • /* Safe Pattern 2: Using compound comparison bounds */
  • data work.youth_correct2;
  • set work.patients;
  • if 0 <= age < 18 then status = 'Minor';
  • run;
  • 3. Arithmetic Expressions vs. SAS Summary Functions

The most heavily tested concept regarding missing values is the distinction between using standard arithmetic operators ( + , - , * , / ) versus SAS sample statistic functions ( SUM() , MEAN() , MIN() , MAX() ). /* Comparing Arithmetic Operators vs. SAS Functions */

  • data work.calc_demo;
  • input Q1 Q2 Q3;
  • /* Method A: Arithmetic Expression */
  • Total_Expr = Q1 + Q2 + Q3;
  • /* Method B: SAS Summary Function */
  • Total_Func = sum(Q1, Q2, Q3);
  • Avg_Func = mean(Q1, Q2, Q3);
  • datalines;
  • 10 20 30
  • 10. 30

. . .

  • ;
  • run;
  • Detailed Evaluation Breakdown
  • Observation Input Total_Expr ( Q1 + Q2 + Q3 ) Total_Func ( SUM(Q1, Q2, Q3) ) Avg_Func ( MEAN(Q1, Q2, Q3) )
  • Row 1: 10, 20, 30 60 60 20 (60 / 3)
  • Row 2: 10, ., 30 . (Missing) 40 20 (40 / 2)
  • Row 3: . , . , . . (Missing) . (Missing) . (Missing)
  • Rules for Arithmetic Propagation vs. Summary Functions

Arithmetic Expression Rule : If any operand in a standard expression ( + , - , * , / ) is missing, the entire result propagates as missing ( . ), and SAS writes a note to the log: NOTE: Missing values were generated as a result of performing an operation on missing values.

SAS Function Rule : SAS summary functions ( SUM , MEAN , MIN , MAX ) automatically ignore missing values among their arguments. The function calculates the statistic using only non-missing values.

All-Missing Exception : A summary function returns a missing value ( . ) only if all arguments passed to it are missing .

Denominator Adjustment in MEAN() : The MEAN() function computes the arithmetic average of non-missing arguments only . In Row 2 above, MEAN(10, ., 30) divides 40 by 2 (the count of non-missing items), yielding 20 , rather than dividing by 3.

4. System Options & The MISSING Statement

SAS provides tools to customize missing value display and handling across reports and DATA steps.

A. System Option MISSING

By default, numeric missing values print as a period ( . ) in PROC PRINT and PROC REPORT . The OPTIONS MISSING= global statement changes the character used to display numeric missing values in output reports: /* Display numeric missing values as a blank space in printed reports */

options missing=' ';

  • /* Display numeric missing values as 'N/A' (single character limit in Base SAS) */
  • options missing='N';
  • B. The MISSING Statement in DATA Steps

When reading raw data files containing custom missing value characters (e.g., 'N' or 'a' ), the MISSING statement informs SAS to interpret those specific characters as special numeric missing values during ingestion: data work.survey;

  • missing N R;
  • input id score1 score2;
  • datalines;
  • 101 85 90
  • 102 N 95
  • 103 78 R
  • ;
  • run;

In this example, record 102 will store score1 as special missing value .N , and record 103 will store score2 as .R .