Clinwright Public work of Helper Software LLC · free Start free

14.3.1.2

Treatment-Emergent Adverse Events by System Organ Class and Preferred Term

Made 2026-10-17 from simulated data.

ONCO-EX

Table 14.3.1.2

Treatment-Emergent Adverse Events by System Organ Class and Preferred Term

Safety Analysis Set

Standard of Care (N=150)Clinwrightinib 200 mg (N=150)Total (N=300)
Subjects with any event142 (94.7%) [480]146 (97.3%) [707]288 (96.0%) [1187]
CARDIAC DISORDERS34 (22.7%) [35]58 (38.7%) [66]92 (30.7%) [101]
SINUS BRADYCARDIA2 (1.3%) [2]24 (16.0%) [24]26 (8.7%) [26]
MYOCARDIAL INFARCTION8 (5.3%) [8]14 (9.3%) [14]22 (7.3%) [22]
ATRIOVENTRICULAR BLOCK SECOND DEGREE2 (1.3%) [2]8 (5.3%) [8]10 (3.3%) [10]
ATRIAL FIBRILLATION0 (0.0%) [0]8 (5.3%) [8]8 (2.7%) [8]
ATRIAL FLUTTER0 (0.0%) [0]6 (4.0%) [6]6 (2.0%) [6]
ATRIAL HYPERTROPHY6 (4.0%) [6]0 (0.0%) [0]6 (2.0%) [6]
SUPRAVENTRICULAR EXTRASYSTOLES2 (1.3%) [2]3 (2.0%) [3]5 (1.7%) [5]
BRADYCARDIA4 (2.7%) [4]0 (0.0%) [0]4 (1.3%) [4]
TACHYCARDIA3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
ATRIOVENTRICULAR BLOCK FIRST DEGREE2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
BUNDLE BRANCH BLOCK LEFT2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
CARDIAC DISORDER0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
VENTRICULAR HYPERTROPHY2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
BUNDLE BRANCH BLOCK RIGHT1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
CARDIAC FAILURE CONGESTIVE1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
VENTRICULAR EXTRASYSTOLES0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
CONGENITAL, FAMILIAL AND GENETIC DISORDERS0 (0.0%) [0]6 (4.0%) [6]6 (2.0%) [6]
VENTRICULAR SEPTAL DEFECT0 (0.0%) [0]6 (4.0%) [6]6 (2.0%) [6]
EAR AND LABYRINTH DISORDERS4 (2.7%) [4]1 (0.7%) [1]5 (1.7%) [5]
EAR PAIN4 (2.7%) [4]0 (0.0%) [0]4 (1.3%) [4]
VERTIGO0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
EYE DISORDERS14 (9.3%) [14]7 (4.7%) [7]21 (7.0%) [21]
CONJUNCTIVITIS7 (4.7%) [7]0 (0.0%) [0]7 (2.3%) [7]
VISION BLURRED0 (0.0%) [0]7 (4.7%) [7]7 (2.3%) [7]
EYE ALLERGY2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
EYE SWELLING2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
GLAUCOMA2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
EYE PRURITUS1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
GASTROINTESTINAL DISORDERS41 (27.3%) [42]55 (36.7%) [64]96 (32.0%) [106]
NAUSEA7 (4.7%) [7]26 (17.3%) [26]33 (11.0%) [33]
DIARRHOEA18 (12.0%) [18]6 (4.0%) [6]24 (8.0%) [24]
VOMITING3 (2.0%) [3]12 (8.0%) [12]15 (5.0%) [15]
SALIVARY HYPERSECRETION0 (0.0%) [0]7 (4.7%) [7]7 (2.3%) [7]
ABDOMINAL PAIN3 (2.0%) [3]3 (2.0%) [3]6 (2.0%) [6]
DYSPEPSIA4 (2.7%) [4]1 (0.7%) [1]5 (1.7%) [5]
ABDOMINAL DISCOMFORT0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
FLATULENCE3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
GASTROINTESTINAL HAEMORRHAGE0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
HIATUS HERNIA3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
STOMACH DISCOMFORT0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
GASTROOESOPHAGEAL REFLUX DISEASE1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONS64 (42.7%) [84]107 (71.3%) [203]171 (57.0%) [287]
APPLICATION SITE PRURITUS4 (2.7%) [4]46 (30.7%) [46]50 (16.7%) [50]
APPLICATION SITE ERYTHEMA9 (6.0%) [9]39 (26.0%) [39]48 (16.0%) [48]
APPLICATION SITE IRRITATION10 (6.7%) [10]34 (22.7%) [34]44 (14.7%) [44]
APPLICATION SITE DERMATITIS22 (14.7%) [22]20 (13.3%) [20]42 (14.0%) [42]
APPLICATION SITE VESICLES3 (2.0%) [3]14 (9.3%) [14]17 (5.7%) [17]
OEDEMA PERIPHERAL12 (8.0%) [12]5 (3.3%) [5]17 (5.7%) [17]
FATIGUE4 (2.7%) [4]10 (6.7%) [10]14 (4.7%) [14]
APPLICATION SITE REACTION7 (4.7%) [7]2 (1.3%) [2]9 (3.0%) [9]
APPLICATION SITE PERSPIRATION0 (0.0%) [0]6 (4.0%) [6]6 (2.0%) [6]
CHILLS4 (2.7%) [4]2 (1.3%) [2]6 (2.0%) [6]
ASTHENIA4 (2.7%) [4]1 (0.7%) [1]5 (1.7%) [5]
APPLICATION SITE PAIN0 (0.0%) [0]4 (2.7%) [4]4 (1.3%) [4]
APPLICATION SITE SWELLING0 (0.0%) [0]4 (2.7%) [4]4 (1.3%) [4]
APPLICATION SITE URTICARIA0 (0.0%) [0]4 (2.7%) [4]4 (1.3%) [4]
CHEST DISCOMFORT0 (0.0%) [0]4 (2.7%) [4]4 (1.3%) [4]
APPLICATION SITE INDURATION3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
PYREXIA2 (1.3%) [2]1 (0.7%) [1]3 (1.0%) [3]
FEELING COLD0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
MALAISE0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
APPLICATION SITE DISCHARGE0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
CHEST PAIN0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
FEELING ABNORMAL0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
HEPATOBILIARY DISORDERS3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
HYPERBILIRUBINAEMIA3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
IMMUNE SYSTEM DISORDERS0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
SEASONAL ALLERGY0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
INFECTIONS AND INFESTATIONS49 (32.7%) [59]31 (20.7%) [34]80 (26.7%) [93]
UPPER RESPIRATORY TRACT INFECTION26 (17.3%) [26]10 (6.7%) [10]36 (12.0%) [36]
NASOPHARYNGITIS2 (1.3%) [2]9 (6.0%) [9]11 (3.7%) [11]
EAR INFECTION8 (5.3%) [8]0 (0.0%) [0]8 (2.7%) [8]
INFLUENZA4 (2.7%) [4]3 (2.0%) [3]7 (2.3%) [7]
URINARY TRACT INFECTION4 (2.7%) [4]2 (1.3%) [2]6 (2.0%) [6]
LOWER RESPIRATORY TRACT INFECTION0 (0.0%) [0]5 (3.3%) [5]5 (1.7%) [5]
CERVICITIS4 (2.7%) [4]0 (0.0%) [0]4 (1.3%) [4]
BRONCHITIS3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
GASTROENTERITIS VIRAL3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
CYSTITIS1 (0.7%) [1]1 (0.7%) [1]2 (0.7%) [2]
LOCALISED INFECTION2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
PNEUMONIA1 (0.7%) [1]1 (0.7%) [1]2 (0.7%) [2]
RHINITIS0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
HORDEOLUM0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
VAGINAL MYCOSIS1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
INJURY, POISONING AND PROCEDURAL COMPLICATIONS9 (6.0%) [10]17 (11.3%) [18]26 (8.7%) [28]
CONTUSION0 (0.0%) [0]13 (8.7%) [13]13 (4.3%) [13]
HIP FRACTURE5 (3.3%) [5]2 (1.3%) [2]7 (2.3%) [7]
EXCORIATION3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
FACIAL BONES FRACTURE0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
SKIN LACERATION2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
FALL0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
INVESTIGATIONS29 (19.3%) [31]13 (8.7%) [14]42 (14.0%) [45]
HEART RATE IRREGULAR8 (5.3%) [8]0 (0.0%) [0]8 (2.7%) [8]
ELECTROCARDIOGRAM T WAVE INVERSION3 (2.0%) [3]3 (2.0%) [3]6 (2.0%) [6]
HEART RATE INCREASED5 (3.3%) [5]0 (0.0%) [0]5 (1.7%) [5]
ELECTROCARDIOGRAM ST SEGMENT DEPRESSION4 (2.7%) [4]0 (0.0%) [0]4 (1.3%) [4]
WEIGHT DECREASED0 (0.0%) [0]4 (2.7%) [4]4 (1.3%) [4]
BLOOD CREATINE PHOSPHOKINASE INCREASED3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
BLOOD GLUCOSE INCREASED0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
BLOOD URINE PRESENT3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
BLOOD CHOLESTEROL INCREASED0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
CYSTOSCOPY2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
ELECTROCARDIOGRAM T WAVE AMPLITUDE DECREASED2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
BIOPSY0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
BIOPSY PROSTATE0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
BLOOD ALKALINE PHOSPHATASE INCREASED1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
METABOLISM AND NUTRITION DISORDERS16 (10.7%) [17]8 (5.3%) [8]24 (8.0%) [25]
INCREASED APPETITE8 (5.3%) [8]4 (2.7%) [4]12 (4.0%) [12]
DECREASED APPETITE3 (2.0%) [3]4 (2.7%) [4]7 (2.3%) [7]
DEHYDRATION2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
DIABETES MELLITUS2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
FOOD CRAVING2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
MUSCULOSKELETAL AND CONNECTIVE TISSUE DISORDERS12 (8.0%) [12]14 (9.3%) [14]26 (8.7%) [26]
BACK PAIN2 (1.3%) [2]6 (4.0%) [6]8 (2.7%) [8]
SHOULDER PAIN5 (3.3%) [5]0 (0.0%) [0]5 (1.7%) [5]
ARTHRITIS2 (1.3%) [2]2 (1.3%) [2]4 (1.3%) [4]
FLANK PAIN0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
ARTHRALGIA1 (0.7%) [1]1 (0.7%) [1]2 (0.7%) [2]
MUSCLE SPASMS0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
PAIN IN EXTREMITY2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
NEOPLASMS BENIGN, MALIGNANT AND UNSPECIFIED (INCL CYSTS AND POLYPS)0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
PROSTATE CANCER0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
NERVOUS SYSTEM DISORDERS23 (15.3%) [27]51 (34.0%) [59]74 (24.7%) [86]
DIZZINESS4 (2.7%) [4]23 (15.3%) [23]27 (9.0%) [27]
HEADACHE13 (8.7%) [13]11 (7.3%) [11]24 (8.0%) [24]
SOMNOLENCE5 (3.3%) [5]2 (1.3%) [2]7 (2.3%) [7]
PAROSMIA0 (0.0%) [0]6 (4.0%) [6]6 (2.0%) [6]
PARKINSON'S DISEASE4 (2.7%) [4]0 (0.0%) [0]4 (1.3%) [4]
AMNESIA0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
SYNCOPE0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
SYNCOPE VASOVAGAL0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
BURNING SENSATION0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
HYPERSOMNIA0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
PARTIAL SEIZURES WITH SECONDARY GENERALISATION0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
COGNITIVE DISORDER0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
LETHARGY0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
PSYCHOMOTOR HYPERACTIVITY1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
PSYCHIATRIC DISORDERS17 (11.3%) [19]11 (7.3%) [11]28 (9.3%) [30]
CONFUSIONAL STATE5 (3.3%) [5]0 (0.0%) [0]5 (1.7%) [5]
INSOMNIA3 (2.0%) [3]2 (1.3%) [2]5 (1.7%) [5]
HALLUCINATION, VISUAL0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
IRRITABILITY3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
LIBIDO DECREASED0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
AGITATION2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
ANXIETY2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
COMPLETED SUICIDE2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
DELIRIUM0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
DELUSION1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
DEPRESSED MOOD0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
DISORIENTATION1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
HALLUCINATION0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
RENAL AND URINARY DISORDERS4 (2.7%) [4]5 (3.3%) [5]9 (3.0%) [9]
POLLAKIURIA4 (2.7%) [4]0 (0.0%) [0]4 (1.3%) [4]
NEPHROLITHIASIS0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
CALCULUS URETHRAL0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
REPRODUCTIVE SYSTEM AND BREAST DISORDERS6 (4.0%) [6]3 (2.0%) [3]9 (3.0%) [9]
BENIGN PROSTATIC HYPERPLASIA4 (2.7%) [4]3 (2.0%) [3]7 (2.3%) [7]
PELVIC PAIN2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
RESPIRATORY, THORACIC AND MEDIASTINAL DISORDERS24 (16.0%) [24]27 (18.0%) [29]51 (17.0%) [53]
COUGH5 (3.3%) [5]13 (8.7%) [13]18 (6.0%) [18]
NASAL CONGESTION8 (5.3%) [8]5 (3.3%) [5]13 (4.3%) [13]
POSTNASAL DRIP5 (3.3%) [5]0 (0.0%) [0]5 (1.7%) [5]
PRODUCTIVE COUGH0 (0.0%) [0]5 (3.3%) [5]5 (1.7%) [5]
EMPHYSEMA3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
PHARYNGEAL ERYTHEMA0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
RALES2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
RESPIRATORY TRACT CONGESTION0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
DYSPNOEA1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
EPISTAXIS0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
RHINORRHOEA0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
SKIN AND SUBCUTANEOUS TISSUE DISORDERS62 (41.3%) [77]101 (67.3%) [150]163 (54.3%) [227]
PRURITUS15 (10.0%) [15]51 (34.0%) [51]66 (22.0%) [66]
ERYTHEMA22 (14.7%) [22]34 (22.7%) [34]56 (18.7%) [56]
RASH15 (10.0%) [15]20 (13.3%) [20]35 (11.7%) [35]
SKIN IRRITATION9 (6.0%) [9]10 (6.7%) [10]19 (6.3%) [19]
HYPERHIDROSIS3 (2.0%) [3]11 (7.3%) [11]14 (4.7%) [14]
BLISTER0 (0.0%) [0]6 (4.0%) [6]6 (2.0%) [6]
COLD SWEAT6 (4.0%) [6]0 (0.0%) [0]6 (2.0%) [6]
RASH MACULO-PAPULAR0 (0.0%) [0]4 (2.7%) [4]4 (1.3%) [4]
RASH PRURITIC0 (0.0%) [0]4 (2.7%) [4]4 (1.3%) [4]
PRURITUS GENERALISED0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
RASH PAPULAR0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
SKIN ULCER3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
DERMATITIS ATOPIC2 (1.3%) [2]0 (0.0%) [0]2 (0.7%) [2]
URTICARIA0 (0.0%) [0]2 (1.3%) [2]2 (0.7%) [2]
ACTINIC KERATOSIS0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
ALOPECIA1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
DRUG ERUPTION1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
SKIN ODOUR ABNORMAL0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
SOCIAL CIRCUMSTANCES0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
ALCOHOL USE0 (0.0%) [0]1 (0.7%) [1]1 (0.3%) [1]
SURGICAL AND MEDICAL PROCEDURES1 (0.7%) [1]3 (2.0%) [3]4 (1.3%) [4]
SKIN LESION EXCISION0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]
EYE LASER SURGERY1 (0.7%) [1]0 (0.0%) [0]1 (0.3%) [1]
VASCULAR DISORDERS11 (7.3%) [11]7 (4.7%) [7]18 (6.0%) [18]
HYPERTENSION4 (2.7%) [4]4 (2.7%) [4]8 (2.7%) [8]
HYPOTENSION4 (2.7%) [4]0 (0.0%) [0]4 (1.3%) [4]
ORTHOSTATIC HYPOTENSION3 (2.0%) [3]0 (0.0%) [0]3 (1.0%) [3]
WOUND HAEMORRHAGE0 (0.0%) [0]3 (2.0%) [3]3 (1.0%) [3]

n (%) [E]: subjects with at least one event (percent of N) [number of events].

System organ classes in alphabetical order, preferred terms by decreasing frequency in the total.

Source: ADAE.

Program: t-14-3-1-2.sas

Program t-14-3-1-2.sas

Version 1, written from Clinwright's patterns, 2026-10-17, checks passed.

/*==== 00-header ====*/
/*----------------------------------------------------------------------------
  Output  : Table 14.3.1.2 / Treatment-Emergent Adverse Events by System Organ Class and Preferred Term / Safety Analysis Set
  Program : t-14-3-1-2.sas   Reporting effort : CSR
  ADaM    : /work/adam (ADSL, ADLBC, ADLBH, ADVS, ADAE, ADEG, ADCM, ADMH, ADEX, ADRS, ADTR, ADTTE)
  The header and the report step follow from the shell. The sections between
  them make WORK.FINAL, one record per row of the table, in order:
    _page     the page (1 unless the output is paged); _pagelbl its heading or empty
    _ord      the row's order; _indent the label's indentation (0 = flush left)
    _rowid    the uuid of the shell row it shows (WORK._SHELL); one shell row may
              have several (a category per value); a blank row's is blank-<n>
    _kind     label | stat | blank
    rowlabel  the row's label, as text
    col1      Standard of Care|(N=xx)
    col2      Clinwrightinib 200 mg|(N=xx)
    col3      Total|(N=xx)
  and set the big N of the column headers:
    &_bign1    Standard of Care|(N=xx)
    &_bign2    Clinwrightinib 200 mg|(N=xx)
    &_bign3    Total|(N=xx)
  /work/_lib/clinwright.sas has %ls_bign, %ls_count, %ls_stats, %ls_npct, %ls_num.
----------------------------------------------------------------------------*/
libname adam "/work/adam" access=readonly;
%include "/work/_lib/clinwright.sas";
%ls_setup;

/* The shell's rows, in order, with each column's value pattern (_xx1-_xx3). */
data work._shell;
  length _page 8 _pagelbl $200 _ord 8 _indent 8 _rowid $36 _kind $5 _var $32 rowlabel $200 _xx1 $40 _xx2 $40 _xx3 $40;
  _page = 1; _pagelbl = '';
  _ord=1; _indent=0; _rowid='6da962c1-84d7-4a41-9e7f-1f93e4978920'; _kind='stat'; _var=''; rowlabel='Subjects with any event'; _xx1='xx (xx.x%) [xx]'; _xx2='xx (xx.x%) [xx]'; _xx3='xx (xx.x%) [xx]'; output;
  _ord=2; _indent=0; _rowid='blank-2'; _kind='blank'; _var=''; rowlabel=''; _xx1=''; _xx2=''; _xx3=''; output;
  _ord=3; _indent=0; _rowid='c83483a1-af55-4b18-b2f8-85ff573e6433'; _kind='stat'; _var='AEBODSYS'; rowlabel='[System organ class]'; _xx1='xx (xx.x%) [xx]'; _xx2='xx (xx.x%) [xx]'; _xx3='xx (xx.x%) [xx]'; output;
  _ord=4; _indent=1; _rowid='a0898927-1d1b-46db-ad78-04e9df02c40c'; _kind='stat'; _var='AEDECOD'; rowlabel='[Preferred term]'; _xx1='xx (xx.x%) [xx]'; _xx2='xx (xx.x%) [xx]'; _xx3='xx (xx.x%) [xx]'; output;
run;

/*==== 10-data ====*/
/* Made from the output's analysis: the records of ADAE with TRTEMFL = 'Y' of the subjects of ADSL with SAFFL = 'Y', by TRT01A. */
/* The population's subjects, in each column they count in. */
data work._popc;
  set adam.adsl(where=(saffl = 'Y'));
  if trt01a in ('Standard of Care') then do; _col = 1; output; end;
  if trt01a in ('Clinwrightinib 200 mg') then do; _col = 2; output; end;
  _col = 3; output;
  keep usubjid _col;
run;
data work._pop1; set adam.adsl(where=(saffl = 'Y')); keep usubjid trt01a; run;
proc sort data=work._pop1; by usubjid; run;
/* The records of ADAE with TRTEMFL = 'Y', of the population's subjects, in each column. */
proc sort data=adam.adae(keep=usubjid saffl aedecod aebodsys trtemfl where=(TRTEMFL = 'Y')) out=work._rec; by usubjid; run;
data work._an;
  merge work._rec(in=_r) work._pop1(in=_p);
  by usubjid;
  if _r and _p;
  if trt01a in ('Standard of Care') then do; _col = 1; output; end;
  if trt01a in ('Clinwrightinib 200 mg') then do; _col = 2; output; end;
  _col = 3; output;
run;
data work._cols; do _col = 1 to 3; output; end; run;
%ls_bign(data=work._popc, trt=_col, values=1|2|3|1|2|3, names=_lsn1 _lsn2 _lsn3 _bign1 _bign2 _bign3);

/* Subjects and records per column. */
proc sort data=work._an(keep=usubjid _col) out=work._u; by _col usubjid; run;
data work._c;
  set work._u;
  by _col usubjid;
  retain _n _e;
  if first._col then do; _n = 0; _e = 0; end;
  _e = _e + 1;
  if first.usubjid then _n = _n + 1;
  if last._col then output;
  keep _col _n _e;
run;
proc transpose data=work._c out=work._tn(drop=_name_) prefix=_n; id _col; var _n; run;
proc transpose data=work._c out=work._te(drop=_name_) prefix=_e; id _col; var _e; run;
data work._z; _z = 1; run;
data work._g0;
  merge work._z work._tn work._te;
  array _nn{3} _n1-_n3;
  array _ee{3} _e1-_e3;
  do _i = 1 to 3; _nn{_i} = sum(_nn{_i}, 0); _ee{_i} = sum(_ee{_i}, 0); end;
  _tot = _n3;
  drop _i _z;
run;
/* Subjects with any event: any. */
data work._f; set work._g0; do _col = 1 to 3; output; end; run;
data work._k1;
  length _rowid $36 _label _pagelbl $200 _v $200;
  set work._f;
  array _nn{3} _n1-_n3;
  array _ee{3} _e1-_e3;
  _rowid = '6da962c1-84d7-4a41-9e7f-1f93e4978920';
  _page = 1;
  _pagelbl = '';
  _k0 = 1;
  _k1 = 0; _k2 = 0;
  _k3 = 0; _k4 = 0;
  _label = '';
  _v = strip(ifc(missing(_nn{_col}), '-', %ls_num(_nn{_col}, 0))) || ' (' || strip(ifc(missing(ifn(input(symget(cats('_lsn', _col)), 8.) > 0, 100 * _nn{_col} / max(input(symget(cats('_lsn', _col)), 8.), 1), .)), '-', %ls_num(ifn(input(symget(cats('_lsn', _col)), 8.) > 0, 100 * _nn{_col} / max(input(symget(cats('_lsn', _col)), 8.), 1), .), 1))) || '%) [' || strip(ifc(missing(_ee{_col}), '-', %ls_num(_ee{_col}, 0))) || ']';
  keep _rowid _label _page _pagelbl _k0 _k1 _k2 _k3 _k4 _col _v;
run;
/* Per value of aebodsys: subjects and records per column. */
proc sort data=work._an(keep=usubjid _col aebodsys where=(not missing(aebodsys))) out=work._u; by aebodsys _col usubjid; run;
data work._c;
  set work._u;
  by aebodsys _col usubjid;
  retain _n _e;
  if first._col then do; _n = 0; _e = 0; end;
  _e = _e + 1;
  if first.usubjid then _n = _n + 1;
  if last._col then output;
  keep aebodsys _col _n _e;
run;
proc transpose data=work._c out=work._tn(drop=_name_) prefix=_n; by aebodsys; id _col; var _n; run;
proc transpose data=work._c out=work._te(drop=_name_) prefix=_e; by aebodsys; id _col; var _e; run;
data work._g1;
  merge work._tn work._te; by aebodsys;
  array _nn{3} _n1-_n3;
  array _ee{3} _e1-_e3;
  do _i = 1 to 3; _nn{_i} = sum(_nn{_i}, 0); _ee{_i} = sum(_ee{_i}, 0); end;
  _tot = _n3;
  drop _i;
run;
proc sort data=work._g1; by  aebodsys; run;
data work._g1;
  set work._g1;
  _o1 = _n_;
run;
/* [System organ class]: npct of AEBODSYS. */
data work._f; set work._g1; do _col = 1 to 3; output; end; run;
proc sort data=work._f; by aebodsys _col; run;
data work._k2;
  length _rowid $36 _label _pagelbl $200 _v $200;
  set work._f;
  array _nn{3} _n1-_n3;
  array _ee{3} _e1-_e3;
  _rowid = 'c83483a1-af55-4b18-b2f8-85ff573e6433';
  _page = 1;
  _pagelbl = '';
  _k0 = 3;
  _k1 = _o1; _k2 = 0;
  _k3 = 0; _k4 = 0;
  _label = strip(aebodsys);
  _v = strip(ifc(missing(_nn{_col}), '-', %ls_num(_nn{_col}, 0))) || ' (' || strip(ifc(missing(ifn(input(symget(cats('_lsn', _col)), 8.) > 0, 100 * _nn{_col} / max(input(symget(cats('_lsn', _col)), 8.), 1), .)), '-', %ls_num(ifn(input(symget(cats('_lsn', _col)), 8.) > 0, 100 * _nn{_col} / max(input(symget(cats('_lsn', _col)), 8.), 1), .), 1))) || '%) [' || strip(ifc(missing(_ee{_col}), '-', %ls_num(_ee{_col}, 0))) || ']';
  keep _rowid _label _page _pagelbl _k0 _k1 _k2 _k3 _k4 _col _v;
run;
/* Per value of aebodsys and aedecod: subjects and records per column. */
proc sort data=work._an(keep=usubjid _col aebodsys aedecod where=(not missing(aebodsys) and not missing(aedecod))) out=work._u; by aebodsys aedecod _col usubjid; run;
data work._c;
  set work._u;
  by aebodsys aedecod _col usubjid;
  retain _n _e;
  if first._col then do; _n = 0; _e = 0; end;
  _e = _e + 1;
  if first.usubjid then _n = _n + 1;
  if last._col then output;
  keep aebodsys aedecod _col _n _e;
run;
proc transpose data=work._c out=work._tn(drop=_name_) prefix=_n; by aebodsys aedecod; id _col; var _n; run;
proc transpose data=work._c out=work._te(drop=_name_) prefix=_e; by aebodsys aedecod; id _col; var _e; run;
data work._g2;
  merge work._tn work._te; by aebodsys aedecod;
  array _nn{3} _n1-_n3;
  array _ee{3} _e1-_e3;
  do _i = 1 to 3; _nn{_i} = sum(_nn{_i}, 0); _ee{_i} = sum(_ee{_i}, 0); end;
  _tot = _n3;
  drop _i;
run;
proc sort data=work._g2; by aebodsys descending _tot aedecod; run;
data work._g2;
  set work._g2;
  by aebodsys;
  retain _r;
  if first.aebodsys then _r = 0;
  _r = _r + 1;
  _o2 = _r;
  drop _r;
run;
proc sort data=work._g2; by aebodsys; run;
proc sort data=work._g1(keep=aebodsys _o1) out=work._gp; by aebodsys; run;
data work._g2; merge work._g2(in=_in) work._gp; by aebodsys; if _in; run;
/* [Preferred term]: npct of AEDECOD. */
data work._f; set work._g2; do _col = 1 to 3; output; end; run;
proc sort data=work._f; by aebodsys aedecod _col; run;
data work._k3;
  length _rowid $36 _label _pagelbl $200 _v $200;
  set work._f;
  array _nn{3} _n1-_n3;
  array _ee{3} _e1-_e3;
  _rowid = 'a0898927-1d1b-46db-ad78-04e9df02c40c';
  _page = 1;
  _pagelbl = '';
  _k0 = 3;
  _k1 = _o1; _k2 = 4;
  _k3 = _o2; _k4 = 0;
  _label = strip(aedecod);
  _v = strip(ifc(missing(_nn{_col}), '-', %ls_num(_nn{_col}, 0))) || ' (' || strip(ifc(missing(ifn(input(symget(cats('_lsn', _col)), 8.) > 0, 100 * _nn{_col} / max(input(symget(cats('_lsn', _col)), 8.), 1), .)), '-', %ls_num(ifn(input(symget(cats('_lsn', _col)), 8.) > 0, 100 * _nn{_col} / max(input(symget(cats('_lsn', _col)), 8.), 1), .), 1))) || '%) [' || strip(ifc(missing(_ee{_col}), '-', %ls_num(_ee{_col}, 0))) || ']';
  keep _rowid _label _page _pagelbl _k0 _k1 _k2 _k3 _k4 _col _v;
run;

data work._cells; set work._k1 work._k2 work._k3; run;
proc sort data=work._cells; by _page _pagelbl _k0 _k1 _k2 _k3 _k4 _rowid _label _col; run;
proc transpose data=work._cells out=work._wide(drop=_name_) prefix=col;
  by _page _pagelbl _k0 _k1 _k2 _k3 _k4 _rowid _label;
  id _col;
  var _v;
run;
proc sort data=work._wide; by _rowid; run;
proc sort data=work._shell(drop=_page _pagelbl) out=work._rows; by _rowid; run;
data work._inst;
  merge work._wide(in=_w) work._rows(in=_s);
  by _rowid;
  if _w and _s;
  if _label ne '' then rowlabel = _label;
run;
data work._fixed;
  set work._shell;
  if _rowid not in ('6da962c1-84d7-4a41-9e7f-1f93e4978920' 'c83483a1-af55-4b18-b2f8-85ff573e6433' 'a0898927-1d1b-46db-ad78-04e9df02c40c');
  _k0 = _ord; _k1 = 0; _k2 = 0; _k3 = 0; _k4 = 0;
run;
data work.final;
  length col1 col2 col3 $200 _pagelbl $200;
  set work._inst work._fixed;
run;
proc sort data=work.final; by _page _k0 _k1 _k2 _k3 _k4; run;
data work.final;
  set work.final;
  _ord = _n_;
  keep _page _pagelbl _ord _indent _rowid _kind rowlabel col1 col2 col3;
run;

/*==== 90-report ====*/
/* 90-report: from the shell; the titles, columns, headers and footnotes are not changed here. */
%ls_need(_bign1 _bign2 _bign3);
%ls_final_check(columns=_page _pagelbl _ord _indent _rowid _kind rowlabel col1 col2 col3);
proc sort data=work.final out=work._report; by _page _ord; run;
data work._report;
  set work._report;
  /* Two spaces per step of indentation: the label column keeps leading spaces (asis=on). */
  if _indent > 0 then rowlabel = repeat(' ', 2 * _indent - 1) || rowlabel;
run;
%let _lspaged = 0;
proc sql noprint; select count(*) into :_lspaged trimmed from work._report where _pagelbl ne ''; quit;

options orientation=portrait;
ods listing close;
ods rtf file="/work/out/t-14-3-1-2.rtf" style=journal;
title1 j=l "ONCO-EX" j=r "Page ~{thispage} of ~{lastpage}";
title2 j=c "Table 14.3.1.2";
title3 j=c "Treatment-Emergent Adverse Events by System Organ Class and Preferred Term";
title4 j=c "Safety Analysis Set";
footnote1 j=l "n (%) [E]: subjects with at least one event (percent of N) [number of events].";
footnote2 j=l "System organ classes in alphabetical order, preferred terms by decreasing frequency in the total.";
footnote3 j=l "Source: ADAE.";
footnote4 j=l "Program: t-14-3-1-2.sas";
%macro _ls_report;
proc report data=work._report nowd split='|' missing style(report)={width=100%};
  column _page _pagelbl _ord _indent _kind rowlabel col1 col2 col3;
  define _page / order order=internal noprint;
  define _pagelbl / order noprint;
  define _ord / order order=internal noprint;
  define _indent / display noprint;
  define _kind / display noprint;
  define rowlabel / display "" style(column)={cellwidth=40% asis=on} style(header)={just=l};
  define col1 / display "Standard of Care|(N=&_bign1.)" style(column)={cellwidth=20% just=c} style(header)={just=c};
  define col2 / display "Clinwrightinib 200 mg|(N=&_bign2.)" style(column)={cellwidth=20% just=c} style(header)={just=c};
  define col3 / display "Total|(N=&_bign3.)" style(column)={cellwidth=20% just=c} style(header)={just=c};
  %if &_lspaged > 0 %then %do;
  compute before _pagelbl / style={just=l};
    line _pagelbl $200.;
  endcomp;
  %end;
  break after _page / page;
run;
%mend _ls_report;
%_ls_report;
ods rtf close;
ods listing;
%ls_final_export;