A little announcement. A lot to explore.

Happy learning!

Explore lessons, including SAS & R programs and practice data.

Search lessons

Type at least 3 characters to see matching lessons.

Open SAS ↗Open R ↗
← SASnRCount Missing Values in Selected Variables

Introduction

  • A common audit question: how many of a given set of columns are missing on each row? — useful for completeness checks, data-quality flags, and reviewer queries.
  • We want a count per row, looking only at the columns we care about, not every column in the dataset.
  • SAS offers CMISS(), which works on both character and numeric inputs — just list the columns to check.
  • Tidyverse uses across() with is.na() and rowSums() to count NAs across selected columns.
  • Base R uses rowSums(is.na(df[, cols])) — the bracket subset picks the columns, is.na() builds a logical matrix, and rowSums() sums each row.
  • This lesson counts missingness across name and score on a small four-row dataset so each value is easy to inspect.

Count Missing Values in Selected Variables