Clinwright Public work of Helper Software LLC · free Start free

ADAE

Adverse Events Analysis Dataset

OCCURRENCE DATA STRUCTURE · one record per subject per adverse event · keys USUBJID, AETERM, ASTDT, AESEQ

Variables

VariableLabelTypeLengthDerivation
STUDYIDStudy IdentifiertextPredecessor ADSL.STUDYID
SITEIDStudy Site IdentifiertextPredecessor ADSL.SITEID
USUBJIDUnique Subject IdentifiertextPredecessor AE.USUBJID
TRTAActual TreatmenttextPredecessor ADSL.TRT01A
TRTANActual Treatment (N)integer8Predecessor ADSL.TRT01AN
AGEAgeinteger8Predecessor ADSL.AGE
AGEGR1Pooled Age Group 1textPredecessor ADSL.AGEGR1
AGEGR1NPooled Age Group 1 (N)integer8Predecessor ADSL.AGEGR1N
RACERacetextPredecessor ADSL.RACE
RACENRace (N)integer8Predecessor ADSL.RACEN
SEXSextextPredecessor ADSL.SEX
SAFFLSafety Population FlagtextPredecessor ADSL.SAFFL
TRTSDTDate of First Exposure to Treatmentinteger8Predecessor ADSL.TRTSDT
TRTEDTDate of Last Exposure to Treatmentinteger8Predecessor ADSL.TRTEDT
ASTDTAnalysis Start Dateinteger8AE.AESTDTC, converted to a numeric SAS date. Some events with partial dates are imputed in a conservative manner. If the day component is missing, a value of '01' is used. If both the month and day are missing no imputation is performed as these dates clearly indicate a start prior to the beginning of treatment. There are no events with completely missing start dates.
ASTDTFAnalysis Start Date Imputation FlagtextASTDTF='D' if the day value within the character date is imputed. Note that only day values needed to be imputed for this study.
ASTDYAnalysis Start Relative Dayinteger8IF ASTDT>=TRTSDT>MISSING then ASTDY=ASTDT-TRTSDT+1 Else if TRTSDT>ASTDT>MISSING then ASTDY=ASTDT-TRTSDT
AENDTAnalysis End Dateinteger8AE.AEENDTC, converted to a numeric SAS date
AENDYAnalysis End Relative Dayinteger8IF AENDT>=TRTSDT>MISSING then AENDY=AENDT-TRTSDT+1 Else if TRTSDT>AENDT>MISSING then AENDY=AENDT-TRTSDT
ADURNAE Duration (N)integer8ADURN=AENDT-ASTDT+1
ADURUAE Duration UnitstextIf ADURN is not missing then ADURU='DAY'
AETERMReported Term for the Adverse EventtextPredecessor AE.AETERM
AELLTLowest Level TermtextPredecessor AE.AELLT
AELLTCDLowest Level Term Codeinteger8Predecessor AE.AELLTCD
AEDECODDictionary-Derived TermtextPredecessor AE.AEDECOD
AEPTCDPreferred Term Codeinteger8Predecessor AE.AEPTCD
AEHLTHigh Level TermtextPredecessor AE.AEHLT
AEHLTCDHigh Level Term Codeinteger8Predecessor AE.AEHLTCD
AEHLGTHigh Level Group TermtextPredecessor AE.AEHLGT
AEHLGTCDHigh Level Group Term Codeinteger8Predecessor AE.AEHLGTCD
AEBODSYSBody System or Organ ClasstextPredecessor AE.AEBODSYS
AESOCPrimary System Organ ClasstextPredecessor AE.AESOC
AESOCCDPrimary System Organ Class Codeinteger8Predecessor AE.AESOCCD
AESEVSeverity/IntensitytextPredecessor AE.AESEV
AESERSerious EventtextPredecessor AE.AESER
AESCANInvolves CancertextPredecessor AE.AESCAN
AESCONGCongenital Anomaly or Birth DefecttextPredecessor AE.AESCONG
AESDISABPersist or Signif Disability/IncapacitytextPredecessor AE.AESDISAB
AESDTHResults in DeathtextPredecessor AE.AESDTH
AESHOSPRequires or Prolongs HospitalizationtextPredecessor AE.AESHOSP
AESLIFEIs Life ThreateningtextPredecessor AE.AESLIFE
AESODOccurred with OverdosetextPredecessor AE.AESOD
AERELCausalitytextPredecessor AE.AEREL
AEACNAction Taken with Study TreatmenttextPredecessor AE.AEACN
AEOUTOutcome of Adverse EventtextPredecessor AE.AEOUT
AESEQSequence Numberinteger8Predecessor AE.AESEQ
TRTEMFLTreatment Emergent Analysis FlagtextIf ASTDT >= TRTSDT > . then TRTEMFL='Y'. Otherwise TRTEMFL='N'
AOCCFL1st Occurrence of Any AE FlagtextSubset to TRTEMFL='Y' and sort by Subject (USUBJID), Start Date (ASTDT), and Sequence Number (AESEQ) and flag the first record (set AOCCFL=?Y?) within each Subject
AOCCSFL1st Occurrence of SOC FlagtextSubset to TRTEMFL='Y' and sort by Subject (USUBJID), System Organ Class (AEBODSYS), Start Date (ASTDT), and Sequence Number (AESEQ) and flag the first record (set AOCCSFL=?Y?) within each Subject and SOC
AOCCPFL1st Occurrence of Preferred Term FlagtextSubset to TRTEMFL='Y' and sort by Subject (USUBJID), System Organ Class (AEBODSYS), Preferred Term (AEDECOD), Start Date (ASTDT), and Sequence Number (AESEQ) and flag the first record (set AOCCPFL=?Y?) within each Subject, SOC, and PT
AOCC02FL1st Occurrence 02 Flag for SerioustextSubset to TRTEMFL='Y' and AESER='Y' and sort by Subject (USUBJID), Start Date (ASTDT), and Sequence Number (AESEQ) and flag the first record (set AOCC02FL=?Y?) within each Subject
AOCC03FL1st Occurrence 03 Flag for Serious SOCtextSubset to TRTEMFL='Y' and AESER='Y' and sort by Subject (USUBJID), System Organ Class (AEBODSYS), Start Date (ASTDT), and Sequence Number (AESEQ) and flag the first record (set AOCC03FL=?Y?) within each Subject and SOC
AOCC04FL1st Occurrence 04 Flag for Serious PTtextSubset to TRTEMFL='Y' and AESER='Y' and sort by Subject (USUBJID), System Organ Class (AEBODSYS), Preferred Term (AEDECOD), Start Date (ASTDT), and Sequence Number (AESEQ) and flag the first record (set AOCC04FL=?Y?) within each Subject, SOC, and PT

Program adae.sas

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

/*==== 00-header ====*/
/*----------------------------------------------------------------------------
  Data set : ADAE (Adverse Events Analysis Dataset)
  Reporting effort : CSR
  SDTM     : AE
  ADaM     : ADSL
  The header and the finalize step follow from the specification.
----------------------------------------------------------------------------*/
libname sdtm "/work/sdtm" access=readonly;
libname adam "/work/adam";
options validvarname=upcase nofmterr msglevel=i;

/*==== 10-inputs ====*/
/* The AE records, with the subject's TRTSDT, TRTEDT, STUDYID, SITEID, TRT01A, TRT01AN, AGE, AGEGR1, AGEGR1N, RACE, RACEN, SEX, SAFFL from ADSL. */
proc sort data=sdtm.ae(keep=studyid usubjid aeseq aeterm aellt aelltcd aedecod aeptcd aehlt aehltcd aehlgt aehlgtcd aebodsys aesoc aesoccd aesev aeser aeacn aerel aeout aescan aescong aesdisab aesdth aeshosp aeslife aesod aestdtc aeendtc) out=work._ds; by usubjid; run;
proc sort data=adam.adsl(keep=usubjid trtsdt trtedt studyid siteid trt01a trt01an age agegr1 agegr1n race racen sex saffl) out=work._adsl; by usubjid; run;
data work._ds;
  merge work._ds(in=_in) work._adsl;
  by usubjid;
  if _in;
  length trta $200;
  trta = trt01a;
  trtan = trt01an;
run;
/* Copies typed as the specification has them. */
data work._ds; set work._ds(rename=(aelltcd=_aelltcd)); aelltcd = input(_aelltcd, ?? best32.); drop _aelltcd; run;
data work._ds; set work._ds(rename=(aeptcd=_aeptcd)); aeptcd = input(_aeptcd, ?? best32.); drop _aeptcd; run;
data work._ds; set work._ds(rename=(aehltcd=_aehltcd)); aehltcd = input(_aehltcd, ?? best32.); drop _aehltcd; run;
data work._ds; set work._ds(rename=(aehlgtcd=_aehlgtcd)); aehlgtcd = input(_aehlgtcd, ?? best32.); drop _aehlgtcd; run;
data work._ds; set work._ds(rename=(aesoccd=_aesoccd)); aesoccd = input(_aesoccd, ?? best32.); drop _aesoccd; run;

/*==== 30-timing ====*/
/* ASTDT: AE.AESTDTC as a SAS date; a date without its day takes the first one. */
data work._ds;
  set work._ds;
  length _dtc $10;
  _dtc = aestdtc; /* (its first 10 characters: SUBSTR would complain of a shorter variable) */
  if length(_dtc) = 10 then astdt = input(_dtc, ?? yymmdd10.);

  else if length(_dtc) = 7 then do; /* yyyy-mm */
    astdt = input(cats(_dtc, '-01'), ?? yymmdd10.);

  end;


  format astdt date9.;
  drop _dtc;
run;

/* ASTDTF: what of ASTDT was imputed from AE.AESTDTC (set where ASTDT is imputed; see LSP-TIMING-DT). */
data work._ds;
  set work._ds;
  length astdtf $1;
  if astdt > . then select (length(substr(aestdtc, 1, 10)));
    when (10) astdtf = '';
    when (7) astdtf = 'D';
    when (4) astdtf = 'M';
    otherwise astdtf = '';
  end;
run;

/* ASTDY: day of ASTDT relative to TRTSDT; no day 0. */
data work._ds;
  set work._ds;
  if nmiss(astdt, trtsdt) = 0 then astdy = astdt - trtsdt + (astdt >= trtsdt);
run;

/* AENDT: AE.AEENDTC as a SAS date. */
data work._ds;
  set work._ds;
  length _dtc $10;
  _dtc = aeendtc; /* (its first 10 characters: SUBSTR would complain of a shorter variable) */
  if length(_dtc) = 10 then aendt = input(_dtc, ?? yymmdd10.);

  format aendt date9.;
  drop _dtc;
run;

/* AENDY: day of AENDT relative to TRTSDT; no day 0. */
data work._ds;
  set work._ds;
  if nmiss(aendt, trtsdt) = 0 then aendy = aendt - trtsdt + (aendt >= trtsdt);
run;

/* ADURN: from ASTDT to AENDT, in days, both days counted. */
data work._ds;
  set work._ds;
  if nmiss(astdt, aendt) = 0 then adurn = (aendt - astdt + 1);
run;

/*==== 60-flags ====*/
/* TRTEMFL: Y if ASTDT >= TRTSDT; otherwise N. */
data work._ds;
  set work._ds;
  length trtemfl $1;
  if . < trtsdt <= astdt then trtemfl = 'Y';
  else trtemfl = 'N';
run;

/* AOCCFL: the first event per subject where TRTEMFL='Y'. */
proc sort data=work._ds(where=(TRTEMFL='Y')) out=work._aoccfl(keep=usubjid  astdt aeseq);
  by usubjid  astdt aeseq;
run;
data work._aoccfl;
  set work._aoccfl;
  by usubjid ;
  if first.usubjid;
  length aoccfl $1;
  aoccfl = 'Y';
run;
proc sort data=work._ds; by usubjid  astdt aeseq; run;
data work._ds;
  merge work._ds work._aoccfl;
  by usubjid  astdt aeseq;
run;

/* AOCCSFL: the first event per subject and AEBODSYS where TRTEMFL='Y'. */
proc sort data=work._ds(where=(TRTEMFL='Y')) out=work._aoccsfl(keep=usubjid aebodsys astdt aeseq);
  by usubjid aebodsys astdt aeseq;
run;
data work._aoccsfl;
  set work._aoccsfl;
  by usubjid aebodsys;
  if first.aebodsys;
  length aoccsfl $1;
  aoccsfl = 'Y';
run;
proc sort data=work._ds; by usubjid aebodsys astdt aeseq; run;
data work._ds;
  merge work._ds work._aoccsfl;
  by usubjid aebodsys astdt aeseq;
run;

/* AOCCPFL: the first event per subject and AEBODSYS, AEDECOD where TRTEMFL='Y'. */
proc sort data=work._ds(where=(TRTEMFL='Y')) out=work._aoccpfl(keep=usubjid aebodsys aedecod astdt aeseq);
  by usubjid aebodsys aedecod astdt aeseq;
run;
data work._aoccpfl;
  set work._aoccpfl;
  by usubjid aebodsys aedecod;
  if first.aedecod;
  length aoccpfl $1;
  aoccpfl = 'Y';
run;
proc sort data=work._ds; by usubjid aebodsys aedecod astdt aeseq; run;
data work._ds;
  merge work._ds work._aoccpfl;
  by usubjid aebodsys aedecod astdt aeseq;
run;

/* AOCC02FL: the first event per subject where TRTEMFL='Y' and AESER='Y'. */
proc sort data=work._ds(where=(TRTEMFL='Y' and AESER='Y')) out=work._aocc02fl(keep=usubjid  astdt aeseq);
  by usubjid  astdt aeseq;
run;
data work._aocc02fl;
  set work._aocc02fl;
  by usubjid ;
  if first.usubjid;
  length aocc02fl $1;
  aocc02fl = 'Y';
run;
proc sort data=work._ds; by usubjid  astdt aeseq; run;
data work._ds;
  merge work._ds work._aocc02fl;
  by usubjid  astdt aeseq;
run;

/* AOCC03FL: the first event per subject and AEBODSYS where TRTEMFL='Y' and AESER='Y'. */
proc sort data=work._ds(where=(TRTEMFL='Y' and AESER='Y')) out=work._aocc03fl(keep=usubjid aebodsys astdt aeseq);
  by usubjid aebodsys astdt aeseq;
run;
data work._aocc03fl;
  set work._aocc03fl;
  by usubjid aebodsys;
  if first.aebodsys;
  length aocc03fl $1;
  aocc03fl = 'Y';
run;
proc sort data=work._ds; by usubjid aebodsys astdt aeseq; run;
data work._ds;
  merge work._ds work._aocc03fl;
  by usubjid aebodsys astdt aeseq;
run;

/* AOCC04FL: the first event per subject and AEBODSYS, AEDECOD where TRTEMFL='Y' and AESER='Y'. */
proc sort data=work._ds(where=(TRTEMFL='Y' and AESER='Y')) out=work._aocc04fl(keep=usubjid aebodsys aedecod astdt aeseq);
  by usubjid aebodsys aedecod astdt aeseq;
run;
data work._aocc04fl;
  set work._aocc04fl;
  by usubjid aebodsys aedecod;
  if first.aedecod;
  length aocc04fl $1;
  aocc04fl = 'Y';
run;
proc sort data=work._ds; by usubjid aebodsys aedecod astdt aeseq; run;
data work._ds;
  merge work._ds work._aocc04fl;
  by usubjid aebodsys aedecod astdt aeseq;
run;

/*==== 70-other ====*/
/* ADURU (AE Duration Units): If ADURN is not missing then ADURU='DAY' -- to write. */

/*==== 89-final ====*/
/* The data set as derived; the finalize step keeps the specification's variables. */
data work._final;
  set work._ds;
run;

/*==== 90-finalize ====*/
/* 90-finalize: from the specification; the variables, their order and attributes are not changed here. */
/* The text variables the specification gives no length: as long as their longest value (at least 1). */
%let _len1 = 1; %let _len2 = 1; %let _len3 = 1; %let _len4 = 1; %let _len5 = 1; %let _len6 = 1; %let _len7 = 1; %let _len8 = 1; %let _len9 = 1; %let _len10 = 1; %let _len11 = 1; %let _len12 = 1; %let _len13 = 1; %let _len14 = 1; %let _len15 = 1; %let _len16 = 1; %let _len17 = 1; %let _len18 = 1; %let _len19 = 1; %let _len20 = 1; %let _len21 = 1; %let _len22 = 1; %let _len23 = 1; %let _len24 = 1; %let _len25 = 1; %let _len26 = 1; %let _len27 = 1; %let _len28 = 1; %let _len29 = 1; %let _len30 = 1; %let _len31 = 1; %let _len32 = 1; %let _len33 = 1; %let _len34 = 1; %let _len35 = 1; %let _len36 = 1;
data _null_;
  length _ren _asg _siz $32767;
  _dsid = open('work._final');
  if varnum(_dsid, 'STUDYID') > 0 then do; _ren = catx(' ', _ren, 'STUDYID=_rz1'); _asg = catx(' ', _asg, 'STUDYID = _rz1;');
    _siz = catx(' ', _siz, '_len1 = max(_len1, lengthn(STUDYID));'); end;
  if varnum(_dsid, 'SITEID') > 0 then do; _ren = catx(' ', _ren, 'SITEID=_rz2'); _asg = catx(' ', _asg, 'SITEID = _rz2;');
    _siz = catx(' ', _siz, '_len2 = max(_len2, lengthn(SITEID));'); end;
  if varnum(_dsid, 'USUBJID') > 0 then do; _ren = catx(' ', _ren, 'USUBJID=_rz3'); _asg = catx(' ', _asg, 'USUBJID = _rz3;');
    _siz = catx(' ', _siz, '_len3 = max(_len3, lengthn(USUBJID));'); end;
  if varnum(_dsid, 'TRTA') > 0 then do; _ren = catx(' ', _ren, 'TRTA=_rz4'); _asg = catx(' ', _asg, 'TRTA = _rz4;');
    _siz = catx(' ', _siz, '_len4 = max(_len4, lengthn(TRTA));'); end;
  if varnum(_dsid, 'AGEGR1') > 0 then do; _ren = catx(' ', _ren, 'AGEGR1=_rz5'); _asg = catx(' ', _asg, 'AGEGR1 = _rz5;');
    _siz = catx(' ', _siz, '_len5 = max(_len5, lengthn(AGEGR1));'); end;
  if varnum(_dsid, 'RACE') > 0 then do; _ren = catx(' ', _ren, 'RACE=_rz6'); _asg = catx(' ', _asg, 'RACE = _rz6;');
    _siz = catx(' ', _siz, '_len6 = max(_len6, lengthn(RACE));'); end;
  if varnum(_dsid, 'SEX') > 0 then do; _ren = catx(' ', _ren, 'SEX=_rz7'); _asg = catx(' ', _asg, 'SEX = _rz7;');
    _siz = catx(' ', _siz, '_len7 = max(_len7, lengthn(SEX));'); end;
  if varnum(_dsid, 'SAFFL') > 0 then do; _ren = catx(' ', _ren, 'SAFFL=_rz8'); _asg = catx(' ', _asg, 'SAFFL = _rz8;');
    _siz = catx(' ', _siz, '_len8 = max(_len8, lengthn(SAFFL));'); end;
  if varnum(_dsid, 'ASTDTF') > 0 then do; _ren = catx(' ', _ren, 'ASTDTF=_rz9'); _asg = catx(' ', _asg, 'ASTDTF = _rz9;');
    _siz = catx(' ', _siz, '_len9 = max(_len9, lengthn(ASTDTF));'); end;
  if varnum(_dsid, 'ADURU') > 0 then do; _ren = catx(' ', _ren, 'ADURU=_rz10'); _asg = catx(' ', _asg, 'ADURU = _rz10;');
    _siz = catx(' ', _siz, '_len10 = max(_len10, lengthn(ADURU));'); end;
  if varnum(_dsid, 'AETERM') > 0 then do; _ren = catx(' ', _ren, 'AETERM=_rz11'); _asg = catx(' ', _asg, 'AETERM = _rz11;');
    _siz = catx(' ', _siz, '_len11 = max(_len11, lengthn(AETERM));'); end;
  if varnum(_dsid, 'AELLT') > 0 then do; _ren = catx(' ', _ren, 'AELLT=_rz12'); _asg = catx(' ', _asg, 'AELLT = _rz12;');
    _siz = catx(' ', _siz, '_len12 = max(_len12, lengthn(AELLT));'); end;
  if varnum(_dsid, 'AEDECOD') > 0 then do; _ren = catx(' ', _ren, 'AEDECOD=_rz13'); _asg = catx(' ', _asg, 'AEDECOD = _rz13;');
    _siz = catx(' ', _siz, '_len13 = max(_len13, lengthn(AEDECOD));'); end;
  if varnum(_dsid, 'AEHLT') > 0 then do; _ren = catx(' ', _ren, 'AEHLT=_rz14'); _asg = catx(' ', _asg, 'AEHLT = _rz14;');
    _siz = catx(' ', _siz, '_len14 = max(_len14, lengthn(AEHLT));'); end;
  if varnum(_dsid, 'AEHLGT') > 0 then do; _ren = catx(' ', _ren, 'AEHLGT=_rz15'); _asg = catx(' ', _asg, 'AEHLGT = _rz15;');
    _siz = catx(' ', _siz, '_len15 = max(_len15, lengthn(AEHLGT));'); end;
  if varnum(_dsid, 'AEBODSYS') > 0 then do; _ren = catx(' ', _ren, 'AEBODSYS=_rz16'); _asg = catx(' ', _asg, 'AEBODSYS = _rz16;');
    _siz = catx(' ', _siz, '_len16 = max(_len16, lengthn(AEBODSYS));'); end;
  if varnum(_dsid, 'AESOC') > 0 then do; _ren = catx(' ', _ren, 'AESOC=_rz17'); _asg = catx(' ', _asg, 'AESOC = _rz17;');
    _siz = catx(' ', _siz, '_len17 = max(_len17, lengthn(AESOC));'); end;
  if varnum(_dsid, 'AESEV') > 0 then do; _ren = catx(' ', _ren, 'AESEV=_rz18'); _asg = catx(' ', _asg, 'AESEV = _rz18;');
    _siz = catx(' ', _siz, '_len18 = max(_len18, lengthn(AESEV));'); end;
  if varnum(_dsid, 'AESER') > 0 then do; _ren = catx(' ', _ren, 'AESER=_rz19'); _asg = catx(' ', _asg, 'AESER = _rz19;');
    _siz = catx(' ', _siz, '_len19 = max(_len19, lengthn(AESER));'); end;
  if varnum(_dsid, 'AESCAN') > 0 then do; _ren = catx(' ', _ren, 'AESCAN=_rz20'); _asg = catx(' ', _asg, 'AESCAN = _rz20;');
    _siz = catx(' ', _siz, '_len20 = max(_len20, lengthn(AESCAN));'); end;
  if varnum(_dsid, 'AESCONG') > 0 then do; _ren = catx(' ', _ren, 'AESCONG=_rz21'); _asg = catx(' ', _asg, 'AESCONG = _rz21;');
    _siz = catx(' ', _siz, '_len21 = max(_len21, lengthn(AESCONG));'); end;
  if varnum(_dsid, 'AESDISAB') > 0 then do; _ren = catx(' ', _ren, 'AESDISAB=_rz22'); _asg = catx(' ', _asg, 'AESDISAB = _rz22;');
    _siz = catx(' ', _siz, '_len22 = max(_len22, lengthn(AESDISAB));'); end;
  if varnum(_dsid, 'AESDTH') > 0 then do; _ren = catx(' ', _ren, 'AESDTH=_rz23'); _asg = catx(' ', _asg, 'AESDTH = _rz23;');
    _siz = catx(' ', _siz, '_len23 = max(_len23, lengthn(AESDTH));'); end;
  if varnum(_dsid, 'AESHOSP') > 0 then do; _ren = catx(' ', _ren, 'AESHOSP=_rz24'); _asg = catx(' ', _asg, 'AESHOSP = _rz24;');
    _siz = catx(' ', _siz, '_len24 = max(_len24, lengthn(AESHOSP));'); end;
  if varnum(_dsid, 'AESLIFE') > 0 then do; _ren = catx(' ', _ren, 'AESLIFE=_rz25'); _asg = catx(' ', _asg, 'AESLIFE = _rz25;');
    _siz = catx(' ', _siz, '_len25 = max(_len25, lengthn(AESLIFE));'); end;
  if varnum(_dsid, 'AESOD') > 0 then do; _ren = catx(' ', _ren, 'AESOD=_rz26'); _asg = catx(' ', _asg, 'AESOD = _rz26;');
    _siz = catx(' ', _siz, '_len26 = max(_len26, lengthn(AESOD));'); end;
  if varnum(_dsid, 'AEREL') > 0 then do; _ren = catx(' ', _ren, 'AEREL=_rz27'); _asg = catx(' ', _asg, 'AEREL = _rz27;');
    _siz = catx(' ', _siz, '_len27 = max(_len27, lengthn(AEREL));'); end;
  if varnum(_dsid, 'AEACN') > 0 then do; _ren = catx(' ', _ren, 'AEACN=_rz28'); _asg = catx(' ', _asg, 'AEACN = _rz28;');
    _siz = catx(' ', _siz, '_len28 = max(_len28, lengthn(AEACN));'); end;
  if varnum(_dsid, 'AEOUT') > 0 then do; _ren = catx(' ', _ren, 'AEOUT=_rz29'); _asg = catx(' ', _asg, 'AEOUT = _rz29;');
    _siz = catx(' ', _siz, '_len29 = max(_len29, lengthn(AEOUT));'); end;
  if varnum(_dsid, 'TRTEMFL') > 0 then do; _ren = catx(' ', _ren, 'TRTEMFL=_rz30'); _asg = catx(' ', _asg, 'TRTEMFL = _rz30;');
    _siz = catx(' ', _siz, '_len30 = max(_len30, lengthn(TRTEMFL));'); end;
  if varnum(_dsid, 'AOCCFL') > 0 then do; _ren = catx(' ', _ren, 'AOCCFL=_rz31'); _asg = catx(' ', _asg, 'AOCCFL = _rz31;');
    _siz = catx(' ', _siz, '_len31 = max(_len31, lengthn(AOCCFL));'); end;
  if varnum(_dsid, 'AOCCSFL') > 0 then do; _ren = catx(' ', _ren, 'AOCCSFL=_rz32'); _asg = catx(' ', _asg, 'AOCCSFL = _rz32;');
    _siz = catx(' ', _siz, '_len32 = max(_len32, lengthn(AOCCSFL));'); end;
  if varnum(_dsid, 'AOCCPFL') > 0 then do; _ren = catx(' ', _ren, 'AOCCPFL=_rz33'); _asg = catx(' ', _asg, 'AOCCPFL = _rz33;');
    _siz = catx(' ', _siz, '_len33 = max(_len33, lengthn(AOCCPFL));'); end;
  if varnum(_dsid, 'AOCC02FL') > 0 then do; _ren = catx(' ', _ren, 'AOCC02FL=_rz34'); _asg = catx(' ', _asg, 'AOCC02FL = _rz34;');
    _siz = catx(' ', _siz, '_len34 = max(_len34, lengthn(AOCC02FL));'); end;
  if varnum(_dsid, 'AOCC03FL') > 0 then do; _ren = catx(' ', _ren, 'AOCC03FL=_rz35'); _asg = catx(' ', _asg, 'AOCC03FL = _rz35;');
    _siz = catx(' ', _siz, '_len35 = max(_len35, lengthn(AOCC03FL));'); end;
  if varnum(_dsid, 'AOCC04FL') > 0 then do; _ren = catx(' ', _ren, 'AOCC04FL=_rz36'); _asg = catx(' ', _asg, 'AOCC04FL = _rz36;');
    _siz = catx(' ', _siz, '_len36 = max(_len36, lengthn(AOCC04FL));'); end;
  _rc = close(_dsid);
  if _ren ne '' then _ren = cats('(rename=(', _ren, '))');
  call symputx('_ren', _ren);
  call symputx('_asg', _asg);
  call symputx('_siz', _siz);
run;
data _null_;
  set work._final end=_end;
  retain _len1 1 _len2 1 _len3 1 _len4 1 _len5 1 _len6 1 _len7 1 _len8 1 _len9 1 _len10 1 _len11 1 _len12 1 _len13 1 _len14 1 _len15 1 _len16 1 _len17 1 _len18 1 _len19 1 _len20 1 _len21 1 _len22 1 _len23 1 _len24 1 _len25 1 _len26 1 _len27 1 _len28 1 _len29 1 _len30 1 _len31 1 _len32 1 _len33 1 _len34 1 _len35 1 _len36 1;
  &_siz
  if _end then do;
    call symputx('_len1', _len1);
    call symputx('_len2', _len2);
    call symputx('_len3', _len3);
    call symputx('_len4', _len4);
    call symputx('_len5', _len5);
    call symputx('_len6', _len6);
    call symputx('_len7', _len7);
    call symputx('_len8', _len8);
    call symputx('_len9', _len9);
    call symputx('_len10', _len10);
    call symputx('_len11', _len11);
    call symputx('_len12', _len12);
    call symputx('_len13', _len13);
    call symputx('_len14', _len14);
    call symputx('_len15', _len15);
    call symputx('_len16', _len16);
    call symputx('_len17', _len17);
    call symputx('_len18', _len18);
    call symputx('_len19', _len19);
    call symputx('_len20', _len20);
    call symputx('_len21', _len21);
    call symputx('_len22', _len22);
    call symputx('_len23', _len23);
    call symputx('_len24', _len24);
    call symputx('_len25', _len25);
    call symputx('_len26', _len26);
    call symputx('_len27', _len27);
    call symputx('_len28', _len28);
    call symputx('_len29', _len29);
    call symputx('_len30', _len30);
    call symputx('_len31', _len31);
    call symputx('_len32', _len32);
    call symputx('_len33', _len33);
    call symputx('_len34', _len34);
    call symputx('_len35', _len35);
    call symputx('_len36', _len36);
  end;
run;
data adam.adae(label="Adverse Events Analysis Dataset");
  attrib
    STUDYID  length=$&_len1 label="Study Identifier"
    SITEID   length=$&_len2 label="Study Site Identifier"
    USUBJID  length=$&_len3 label="Unique Subject Identifier"
    TRTA     length=$&_len4 label="Actual Treatment"
    TRTAN    length=8 label="Actual Treatment (N)"
    AGE      length=8 label="Age"
    AGEGR1   length=$&_len5 label="Pooled Age Group 1"
    AGEGR1N  length=8 label="Pooled Age Group 1 (N)"
    RACE     length=$&_len6 label="Race"
    RACEN    length=8 label="Race (N)"
    SEX      length=$&_len7 label="Sex"
    SAFFL    length=$&_len8 label="Safety Population Flag"
    TRTSDT   length=8 label="Date of First Exposure to Treatment" format=DATE9.
    TRTEDT   length=8 label="Date of Last Exposure to Treatment" format=DATE9.
    ASTDT    length=8 label="Analysis Start Date" format=DATE9.
    ASTDTF   length=$&_len9 label="Analysis Start Date Imputation Flag"
    ASTDY    length=8 label="Analysis Start Relative Day"
    AENDT    length=8 label="Analysis End Date" format=DATE9.
    AENDY    length=8 label="Analysis End Relative Day"
    ADURN    length=8 label="AE Duration (N)"
    ADURU    length=$&_len10 label="AE Duration Units"
    AETERM   length=$&_len11 label="Reported Term for the Adverse Event"
    AELLT    length=$&_len12 label="Lowest Level Term"
    AELLTCD  length=8 label="Lowest Level Term Code"
    AEDECOD  length=$&_len13 label="Dictionary-Derived Term"
    AEPTCD   length=8 label="Preferred Term Code"
    AEHLT    length=$&_len14 label="High Level Term"
    AEHLTCD  length=8 label="High Level Term Code"
    AEHLGT   length=$&_len15 label="High Level Group Term"
    AEHLGTCD length=8 label="High Level Group Term Code"
    AEBODSYS length=$&_len16 label="Body System or Organ Class"
    AESOC    length=$&_len17 label="Primary System Organ Class"
    AESOCCD  length=8 label="Primary System Organ Class Code"
    AESEV    length=$&_len18 label="Severity/Intensity"
    AESER    length=$&_len19 label="Serious Event"
    AESCAN   length=$&_len20 label="Involves Cancer"
    AESCONG  length=$&_len21 label="Congenital Anomaly or Birth Defect"
    AESDISAB length=$&_len22 label="Persist or Signif Disability/Incapacity"
    AESDTH   length=$&_len23 label="Results in Death"
    AESHOSP  length=$&_len24 label="Requires or Prolongs Hospitalization"
    AESLIFE  length=$&_len25 label="Is Life Threatening"
    AESOD    length=$&_len26 label="Occurred with Overdose"
    AEREL    length=$&_len27 label="Causality"
    AEACN    length=$&_len28 label="Action Taken with Study Treatment"
    AEOUT    length=$&_len29 label="Outcome of Adverse Event"
    AESEQ    length=8 label="Sequence Number"
    TRTEMFL  length=$&_len30 label="Treatment Emergent Analysis Flag"
    AOCCFL   length=$&_len31 label="1st Occurrence of Any AE Flag"
    AOCCSFL  length=$&_len32 label="1st Occurrence of SOC Flag"
    AOCCPFL  length=$&_len33 label="1st Occurrence of Preferred Term Flag"
    AOCC02FL length=$&_len34 label="1st Occurrence 02 Flag for Serious"
    AOCC03FL length=$&_len35 label="1st Occurrence 03 Flag for Serious SOC"
    AOCC04FL length=$&_len36 label="1st Occurrence 04 Flag for Serious PT"
  ;
  set work._final&_ren;
  &_asg
  keep STUDYID SITEID USUBJID TRTA TRTAN AGE AGEGR1 AGEGR1N RACE RACEN SEX SAFFL TRTSDT TRTEDT ASTDT ASTDTF ASTDY AENDT AENDY ADURN ADURU AETERM AELLT AELLTCD AEDECOD AEPTCD AEHLT AEHLTCD AEHLGT AEHLGTCD AEBODSYS AESOC AESOCCD AESEV AESER AESCAN AESCONG AESDISAB AESDTH AESHOSP AESLIFE AESOD AEREL AEACN AEOUT AESEQ TRTEMFL AOCCFL AOCCSFL AOCCPFL AOCC02FL AOCC03FL AOCC04FL;
run;
proc sort data=adam.adae; by USUBJID AETERM ASTDT AESEQ; run;

Data (first 20 of 1,268 records, simulated)

STUDYIDSITEIDUSUBJIDTRTATRTANAGEAGEGR1AGEGR1NRACERACENSEXSAFFLTRTSDTTRTEDTASTDTASTDTFASTDYAENDTAENDYADURNADURUAETERMAELLTAELLTCDAEDECODAEPTCDAEHLTAEHLTCDAEHLGTAEHLGTCDAEBODSYSAESOCAESOCCDAESEVAESERAESCANAESCONGAESDISABAESDTHAESHOSPAESLIFEAESODAERELAEACNAEOUTAESEQTRTEMFLAOCCFLAOCCSFLAOCCPFLAOCC02FLAOCC03FLAOCC04FL
ONCO-EX701ONCO-EX-701002Standard of Care157<651WHITE1FY2022-02-122022-12-102022-05-251032022-06-2913836APPLICATION SITE ERYTHEMAAPPLICATION SITE REDNESSAPPLICATION SITE ERYTHEMAHLT_0617HLGT_0152GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSGENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSMILDNNNNNNNNNOT RELATEDDOSE REDUCEDRECOVERED/RESOLVED1YYY
ONCO-EX701ONCO-EX-701002Standard of Care157<651WHITE1FY2022-02-122022-12-102022-06-041132022-08-2419482APPLICATION SITE IRRITATIONAPPLICATION SITE BURNINGAPPLICATION SITE IRRITATIONHLT_0061HLGT_0346GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSGENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSMODERATENNNNNNNNPOSSIBLY RELATEDDOSE NOT CHANGEDRECOVERED/RESOLVED2YY
ONCO-EX701ONCO-EX-701002Standard of Care157<651WHITE1FY2022-02-122022-12-102022-11-042662022-11-1327510HEART RATE INCREASEDHEART RATE INCREASEDHEART RATE INCREASEDHLT_0646HLGT_0673INVESTIGATIONSINVESTIGATIONSMILDNNNNNNNNNOT RELATEDDOSE NOT CHANGEDRECOVERED/RESOLVED3YYY
ONCO-EX701ONCO-EX-701002Standard of Care157<651WHITE1FY2022-02-122022-12-102022-07-111502022-07-121512MYOCARDIAL INFARCTIONMYOCARDIAL INFARCTIONMYOCARDIAL INFARCTIONHLT_0649HLGT_0688CARDIAC DISORDERSCARDIAC DISORDERSSEVERENNNNNNNNRELATEDDOSE NOT CHANGEDRECOVERED/RESOLVED4YYY
ONCO-EX701ONCO-EX-701002Standard of Care157<651WHITE1FY2022-02-122022-12-102022-02-1652022-02-1651RASHRASHRASHHLT_0762HLGT_0198SKIN AND SUBCUTANEOUS TISSUE DISORDERSSKIN AND SUBCUTANEOUS TISSUE DISORDERSMODERATENNNNNNNNNOT RELATEDDOSE NOT CHANGEDRECOVERED/RESOLVED5YYYY
ONCO-EX701ONCO-EX-701003Standard of Care158<651WHITE1MY2022-03-172022-10-202022-04-1631ARTHRITISARTHRITISARTHRITISHLT_0019HLGT_0587MUSCULOSKELETAL AND CONNECTIVE TISSUE DISORDERSMUSCULOSKELETAL AND CONNECTIVE TISSUE DISORDERSMILDNNNNNNNNPOSSIBLY RELATEDDOSE NOT CHANGEDNOT RECOVERED/NOT RESOLVED1YYYY
ONCO-EX701ONCO-EX-701004Clinwrightinib 200 mg260<651WHITE1MY2022-03-182023-02-162023-02-05325APPLICATION SITE DERMATITISAPPLICATION SITE RASHAPPLICATION SITE DERMATITISHLT_0343HLGT_0241GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSGENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSMILDNNNNNNNNNOT RELATEDDOSE REDUCEDNOT RECOVERED/NOT RESOLVED1YY
ONCO-EX701ONCO-EX-701004Clinwrightinib 200 mg260<651WHITE1MY2022-03-182023-02-162022-06-08832022-06-2510018APPLICATION SITE PRURITUSAPPLICATION SITE ITCHINGAPPLICATION SITE PRURITUSHLT_0317HLGT_0338GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSGENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSMODERATENNNNNNNNNOT RELATEDDOSE REDUCEDRECOVERED/RESOLVED2YYYY
ONCO-EX701ONCO-EX-701004Clinwrightinib 200 mg260<651WHITE1MY2022-03-182023-02-162022-07-271322022-07-281332ARTHRITISARTHRITISARTHRITISHLT_0019HLGT_0587MUSCULOSKELETAL AND CONNECTIVE TISSUE DISORDERSMUSCULOSKELETAL AND CONNECTIVE TISSUE DISORDERSMODERATENNNNNNNNRELATEDDRUG INTERRUPTEDRECOVERED/RESOLVED3YYY
ONCO-EX701ONCO-EX-701004Clinwrightinib 200 mg260<651WHITE1MY2022-03-182023-02-162022-12-122702022-12-132712PRURITUSITCHINGPRURITUSHLT_0778HLGT_0695SKIN AND SUBCUTANEOUS TISSUE DISORDERSSKIN AND SUBCUTANEOUS TISSUE DISORDERSMILDNNNNNNNNPOSSIBLY RELATEDDOSE NOT CHANGEDRECOVERED/RESOLVED4YYY
ONCO-EX701ONCO-EX-701004Clinwrightinib 200 mg260<651WHITE1MY2022-03-182023-02-162022-12-182762022-12-252838SKIN ODOUR ABNORMALSKIN ODOR ABNORMALSKIN ODOUR ABNORMALHLT_0510HLGT_0184SKIN AND SUBCUTANEOUS TISSUE DISORDERSSKIN AND SUBCUTANEOUS TISSUE DISORDERSMILDNNNNNNNNUNLIKELY RELATEDDOSE NOT CHANGEDRECOVERED/RESOLVED5YY
ONCO-EX701ONCO-EX-701005Clinwrightinib 200 mg262<651WHITE1MY2022-03-312023-03-012022-07-03952022-07-1210410NAUSEANAUSEANAUSEAHLT_0742HLGT_0326GASTROINTESTINAL DISORDERSGASTROINTESTINAL DISORDERSMODERATENNNNNNNNRELATEDDOSE NOT CHANGEDRECOVERED/RESOLVED1YYYY
ONCO-EX701ONCO-EX-701005Clinwrightinib 200 mg262<651WHITE1MY2022-03-312023-03-012022-12-032482024-01-15656409PAROSMIASTRANGE SMELL SENSATIONPAROSMIAHLT_0258HLGT_0471NERVOUS SYSTEM DISORDERSNERVOUS SYSTEM DISORDERSMODERATENNNNNNNNPOSSIBLY RELATEDDOSE NOT CHANGEDRECOVERED/RESOLVED2YYY
ONCO-EX701ONCO-EX-701005Clinwrightinib 200 mg262<651WHITE1MY2022-03-312023-03-012023-02-113182023-02-123192SYNCOPEFAINTINGSYNCOPEHLT_0440HLGT_0310NERVOUS SYSTEM DISORDERSNERVOUS SYSTEM DISORDERSMILDNNNNNNNNUNLIKELY RELATEDDOSE NOT CHANGEDRECOVERED/RESOLVED3YY
ONCO-EX701ONCO-EX-701007Standard of Care163<651WHITE1MY2022-04-192023-02-142023-01-10267DISORIENTATIONDISORIENTATIONDISORIENTATIONHLT_0299HLGT_0307PSYCHIATRIC DISORDERSPSYCHIATRIC DISORDERSMILDNNNNNNNNPOSSIBLY RELATEDDOSE NOT CHANGEDNOT RECOVERED/NOT RESOLVED1YYY
ONCO-EX701ONCO-EX-701007Standard of Care163<651WHITE1MY2022-04-192023-02-142022-06-05482022-06-09525ELECTROCARDIOGRAM T WAVE AMPLITUDE DECREASEDT WAVE FLATTENING OFELECTROCARDIOGRAM T WAVE AMPLITUDE DECREASEDHLT_0037HLGT_0030INVESTIGATIONSINVESTIGATIONSMILDNNNNNNNNNOT RELATEDDOSE NOT CHANGEDRECOVERED/RESOLVED2YYYY
ONCO-EX701ONCO-EX-701007Standard of Care163<651WHITE1MY2022-04-192023-02-142022-09-24159HEART RATE IRREGULARHEARTBEATS IRREGULARHEART RATE IRREGULARHLT_0765HLGT_0140INVESTIGATIONSINVESTIGATIONSSEVERENNNNNNNNNOT RELATEDDOSE NOT CHANGEDNOT RECOVERED/NOT RESOLVED3YY
ONCO-EX701ONCO-EX-701008Clinwrightinib 200 mg254<651WHITE1MY2022-04-262022-11-292022-08-13110APPLICATION SITE ERYTHEMAAPPLICATION SITE REDNESSAPPLICATION SITE ERYTHEMAHLT_0617HLGT_0152GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSGENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSMILDNNNNNNNNUNLIKELY RELATEDDOSE NOT CHANGEDNOT RECOVERED/NOT RESOLVED1YY
ONCO-EX701ONCO-EX-701008Clinwrightinib 200 mg254<651WHITE1MY2022-04-262022-11-292022-07-2288APPLICATION SITE PRURITUSAPPLICATION SITE ITCHINGAPPLICATION SITE PRURITUSHLT_0317HLGT_0338GENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSGENERAL DISORDERS AND ADMINISTRATION SITE CONDITIONSMILDNNNNNNNNNOT RELATEDDOSE NOT CHANGEDNOT RECOVERED/NOT RESOLVED2YYY
ONCO-EX701ONCO-EX-701008Clinwrightinib 200 mg254<651WHITE1MY2022-04-262022-11-292022-07-07732022-07-11775COUGHCOUGHCOUGHHLT_0701HLGT_0280RESPIRATORY, THORACIC AND MEDIASTINAL DISORDERSRESPIRATORY, THORACIC AND MEDIASTINAL DISORDERSMILDNNNNNNNNNOT RELATEDDRUG INTERRUPTEDRECOVERED/RESOLVED3YYY