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 ↗
← SASnRMerging datasets- select unmatched records

Introduction

  • Sometimes we do not want the matched rows from a merge — we want the mismatches. For example, which subjects in the demographics file have no record in the vitals file, or vice versa.
  • SAS flags this by combining MERGE with the in= dataset option and an if condition on the flags.
  • Tidyverse provides anti_join(), which returns only the rows of the left input that do NOT have a match in the right input.
  • Base R achieves the same by subscripting with !(x %in% y) on the join key.
  • This lesson finds subjects that appear in one dataset but not the other, in both directions.
  • After running, we should have the names present in the sex dataset but missing from the ahw dataset, and vice versa.

Merging datasets- select unmatched records