Search lessons

Type at least 3 characters to see matching lessons.

Open SAS ↗Open R ↗
← SASnRFilter Using a Subquery
Advertisement

Introduction

  • A common clinical programming task is to keep records from one dataset only when they match a condition in another — for example, keeping AE records only for subjects in the safety population.
  • In SAS, this is done with a WHERE ... IN (SELECT ...) subquery inside PROC SQL. In R, we use semi_join() in dplyr or %in% subsetting in base R.
  • The subquery pattern avoids bringing extra columns into the result — we only want to filter, not merge.
  • This lesson uses a small ADSL with a SAFFL flag and an ADAE dataset, keeping only AE records for safety-population subjects.
  • After running, we confirm that AE records for subjects outside the safety population are excluded from the result.

Filter Using a Subquery

Advertisement