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 ↗
← SASnRSummarize Age by Treatment Group with Descriptive Statistics

Introduction

  • Clinical summary tables almost always need descriptive statistics for each treatment group plus a Total column covering all treatments combined.
  • Standard request: n, nmiss, mean, sd, min, Q1, median, Q3, max — per treatment level and overall.
  • In SAS we lean on proc summary with a class statement, preloadfmt, and completetypes so every planned level appears in the output even when it has zero rows.
  • In tidyverse we group_by() the treatment and call summarize(), duplicating records in advance to add the Total band.
  • In base R we use aggregate() with a custom function, then unpack the matrix column and rename the results.
  • This lesson summarizes Age for the flagged analysis population (fasfl = "Y") and shows the pattern in all three languages.

Summarize Age by Treatment Group with Descriptive Statistics