The severity breakdown of tab_ae_soc(): one block per system organ class, one preferred term below it, and one row per severity level, split into columns by treatment. Added because a real published shell asks for it – PhUSE contributed/AE/AE_Severity/ builds exactly this table in SAS.

tab_ae_severity(
  adae,
  adsl,
  by = "TRT01P",
  soc_var = "AEBODSYS",
  pt_var = "AEDECOD",
  sev_var = "ASEV",
  sev_levels = NULL,
  ...
)

Arguments

adae

Adverse-event analysis dataset.

adsl

Subject-level analysis dataset; supplies the population denominator, never adae.

by

Column present in both adae and adsl used to split the table into columns. Default "TRT01P".

soc_var

Column in adae holding the system organ class. Default "AEBODSYS".

pt_var

Column in adae holding the preferred term. Default "AEDECOD".

sev_var

Column in adae holding severity or toxicity grade. Default "ASEV". Must have no missing values – impute or exclude them before calling, the way the SAS shell does.

sev_levels

Severity levels in increasing order. Default c("MILD", "MODERATE", "SEVERE"), or the existing levels when sev_var is already a factor. For CTCAE grades pass as.character(1:5).

...

Passed on to tern::count_occurrences_by_grade() for the preferred-term rows – the escape hatch for grade groupings (grade_groups =) or study-specific statistics.

Value

An object of class c("sasparity_ae_severity", "sasparity_table") wrapping an rtables::TableTree.

Details

Each subject is counted once per term, at their worst severity: a subject with two mild and one moderate episode of the same preferred term contributes 1 to the moderate row and 0 to the mild row. tern::count_occurrences_by_grade() does that de-duplication internally, but it decides "worst" by factor level order, so sev_var is converted to a factor with sev_levels in increasing severity and any value outside that set is an error rather than a silently mis-ordered row. As everywhere else in this package the percentage denominator is the subject count in adsl, forced with denom = "N_col".

SAS equivalent

An %aesev macro: PROC FREQ by AEBODSYS*AEDECOD*ASEV after a sort on a numeric severity code (AESEVN) keeping the worst record per subject and term, denominators from adsl – the Table 14.3.x "Adverse Events by System Organ Class, Preferred Term and Maximum Severity" display. See parity_note().

Examples

adsl <- sasparity_example("adsl")
adsl <- adsl[adsl$SAFFL == "Y", ]
adae <- sasparity_example("adae")
tab_ae_severity(adae, adsl)
#> 
#> ── Adverse Events by System Organ Class, Preferred Term and Maximum Severity ──
#> 
#>  SAS equivalent: %aesev macro / PROC FREQ by AEBODSYS*AEDECOD*ASEV after keeping the worst severity per subject and term (Table 14.3.x AEs by SOC, PT and maximum severity)
#>  Denominator: n per column = subjects in `adsl` (10 total); each subject counts once per term, at their worst of MILD < MODERATE < SEVERE
#>                                              A           B       All Patients
#>                                            (N=5)       (N=5)        (N=10)   
#> —————————————————————————————————————————————————————————————————————————————
#> Subjects with ≥ 1 adverse event          3 (60.0%)   3 (60.0%)    6 (60.0%)  
#> CARDIAC DISORDERS                                                            
#>   MILD                                       0           0            0      
#>   MODERATE                                   0           0            0      
#>   SEVERE                                     0       1 (20.0%)    1 (10.0%)  
#>     CARDIAC ARREST                                                           
#>       MILD                                   0           0            0      
#>       MODERATE                               0           0            0      
#>       SEVERE                                 0       1 (20.0%)    1 (10.0%)  
#> GASTROINTESTINAL DISORDERS                                                   
#>   MILD                                   1 (20.0%)       0        1 (10.0%)  
#>   MODERATE                               1 (20.0%)   1 (20.0%)    2 (20.0%)  
#>   SEVERE                                     0           0            0      
#>     NAUSEA                                                                   
#>       MILD                               2 (40.0%)       0        2 (20.0%)  
#>       MODERATE                               0           0            0      
#>       SEVERE                                 0           0            0      
#>     VOMITING                                                                 
#>       MILD                                   0           0            0      
#>       MODERATE                           1 (20.0%)   1 (20.0%)    2 (20.0%)  
#>       SEVERE                                 0           0            0      
#> SKIN AND SUBCUTANEOUS TISSUE DISORDERS                                       
#>   MILD                                       0       1 (20.0%)    1 (10.0%)  
#>   MODERATE                               1 (20.0%)       0        1 (10.0%)  
#>   SEVERE                                     0           0            0      
#>     RASH                                                                     
#>       MILD                                   0       1 (20.0%)    1 (10.0%)  
#>       MODERATE                           1 (20.0%)       0        1 (10.0%)  
#>       SEVERE                                 0           0            0