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 ↗
← SASnRSubset observations and variables

Introduction

  • Real analysis rarely uses a raw dataset as-is — we usually filter to the rows we care about AND pick just the columns we need in the same step.
  • SAS does both in one DATA step: a WHERE clause for rows, plus keep or drop for columns.
  • In tidyverse we chain filter() and select() with the pipe. In base R we combine a logical row index and a column index in a single [ call.
  • This lesson keeps only the male subjects and drops the sex column in one step — a typical pattern when we subset to one treatment group and no longer need the grouping variable.
  • After running, we have a males dataset with only the male rows and no Sex column.

Subset observations and variables