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 ↗
← SASnRFirst dot concept

Introduction

  • Many analyses ask for the first record of each subject, first visit of each subject, first event of each term — the idea of picking the first row inside a group.
  • In SAS, once the data is sorted by the grouping variable, the automatic first. flag becomes TRUE on the first row of each group.
  • Tidyverse reaches the same idea with group_by() + slice(1) or row_number().
  • Base R uses !duplicated(group) after sorting to keep the first occurrence of each group.
  • This lesson shows two small examples on CLASS: a within-group counter, and the lowest-Height subject within each Sex.
  • Both examples rely on sorting first — the definition of "first" only makes sense after we pick an order.

First dot concept