tab_ae_summary.RdThe standard AE overview counts – subjects with at least one adverse
event, at least one serious adverse event, at least one related adverse
event, and a fatal adverse event – each counted once per subject, with
the percentage denominator taken from adsl, never from adae. Built on
tern::count_patients_with_event(), which is designed exactly for this:
a subject who has the same qualifying event recorded on multiple rows of
adae is still counted once.
tab_ae_summary(adae, adsl, by = "TRT01P", ...)Adverse-event analysis dataset (one row per event per subject).
Subject-level analysis dataset; supplies the population
denominator (alt_counts_df in rtables terms) and is the only
source of the column N= shown in the table header.
Column present in both adae and adsl used to split the table
into columns. Default "TRT01P".
Passed on to each tern::count_patients_with_event() call.
An object of class c("sasparity_ae_summary", "sasparity_table")
wrapping an rtables::TableTree.
Criteria are included only when the corresponding flag column exists in
adae: TRTEMFL (any treatment-emergent AE; "at least one adverse event"
falls back to any record in adae when TRTEMFL is absent), AESER
(serious), AEREL (related; any value other than "NONE" counts as
related), and AESDTH (fatal).
tern's tern::count_patients_with_event() defaults its percentage
denominator to "n" – the number of subjects who happen to appear in the
data passed to it – which for a record-level dataset like adae is
exactly the wrong number (every subject in a filtered adae already has
an event, so a naive "at least one AE" row would silently read 100%).
This function fixes denom = "N_col" on every criterion, forcing every
percentage to divide by the adsl-sourced column count instead. That one
argument is deliberately not exposed via ... – it is the specific bug
this function exists to prevent.
A %aesumm macro: PROC FREQ/PROC SQL over adae with a first.usubjid
(or PROC SORT NODUPKEY) de-duplication step per criterion before
counting, denominators taken from adsl – the Table 14.3.1 "Overview of
Adverse Events" display. See parity_note().
adsl <- sasparity_example("adsl")
adsl <- adsl[adsl$SAFFL == "Y", ]
adae <- sasparity_example("adae")
tab_ae_summary(adae, adsl)
#>
#> ── Overview of Adverse Events ──
#>
#> ℹ SAS equivalent: %aesumm macro / PROC FREQ overview counts, subjects de-duplicated per criterion (Table 14.3.1 AE Overview)
#> ℹ Denominator: n per column = subjects in `adsl` (10 total); each row counts a subject at most once
#> A B All Patients
#> (N=5) (N=5) (N=10)
#> —————————————————————————————————————————————————————————————————————————
#> At least one adverse event 3 (60.0%) 3 (60.0%) 6 (60.0%)
#> At least one serious adverse event 1 (20.0%) 1 (20.0%) 2 (20.0%)
#> At least one related adverse event 2 (40.0%) 2 (40.0%) 4 (40.0%)
#> At least one fatal adverse event 0 1 (20.0%) 1 (10.0%)