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 ↗
← SASnRCross-Tabulation: Two-Way Frequency Table

Introduction

  • A two-way frequency table counts how many records fall into each combination of two categorical variables — treatment by sex, AE severity by system organ class, and so on.
  • Clinical programmers run cross-tabulations daily to verify that subject counts balance across treatment arms, to spot data-entry errors, and to feed downstream TFL programs.
  • SAS handles this with PROC FREQ and the TABLES statement; R offers count() plus pivot_wider() in tidyverse and table() in base R.
  • We build a small ADSL-like dataset with 12 subjects split across three treatment groups and two sexes, then cross-tabulate them side by side.
  • After running, we confirm that every cell count adds up to the total number of subjects — no rows lost, no rows duplicated.

Cross-Tabulation: Two-Way Frequency Table