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

Introduction

  • Merging datasets means joining columns — taking two tables that share a key (like USUBJID) and producing a wider table with columns from both sides.
  • This is how we bring together DM + VS (demographics plus vital signs), or ADSL + ADLB (subject-level plus lab-level data).
  • SAS does this with a DATA step using MERGE + BY. Tidyverse offers a family of *_join() functions (left_join, inner_join, full_join). Base R uses merge().
  • This lesson performs a one-to-one merge on USUBJID between two small datasets, producing a combined dataset with the columns of both.
  • After running, each subject has one row with demographic columns from the first input and the extra columns from the second.

Merging datasets