*************************************************************************************************; * * CLIENT: ModernaTX, Inc. * PROTOCOL: mRNA-1273-P301 * * PURPOSE: Create analysis dataset adae * * INPUT FILES: SDTM domains * OUTPUT FILES: ADAE.sas7bdat * * USAGE NOTES: * *************************************************************************************************; * Copyright 2020 Pharmaceutical Product Development, Inc. * All Rights Reserved. *************************************************************************************************; options noquotelenmax; %include "madam.sas"; **Assign global macro variable DSETNAME to reflect the name of the final ADaM dataset**; %global DSETNAME; %let dsetname = adae; %let adslvar=cutoffdt tr01sdt tr01sdtm tr02sdt tr02sdtm TRTSDT tr01edt tr01edtm dose2dt dos2dtm oldos2dt oldo2dtm eosdt TR02EDT AP02SSDT EXTDT %if %index("&ADAM_SPEC.",DSMB) %then %do; old1dtm OLD1DT %end;; **Merge supplemental data onto parent domain**; %revsupp(libin=trans,libout=work,ds=ae,supp=suppae,outds=ae_all); %revsupp(libin=trans,libout=work,ds=ho,supp=suppho,outds=ho_all); %revsupp(libin=trans,libout=work,ds=ds,supp=suppds,outds=ds_all); proc contents data=trans.ae out=cont; run; proc sql noprint; select length into:lencod from cont where NAME='AEDECOD'; select length into:lenspid from cont where NAME='AESPID'; select strip(label) into:labspid from cont where NAME='AESPID'; quit; proc sort data=ho_all out=ho_icu(keep=usubjid hospid hodur hooccur hodecod) nodupkey; by usubjid hospid descending hodur descending hooccur hodecod; where hodecod='ICU' and hocat='ADVERSE EVENTS' and ^missing(hospid); run; data ho_icu2; length aespid $40.; set ho_icu; _count_spid = count(hospid,'/'); if _count_spid>10 then do; _war = 'Put Aler'||'t_R: HOSPID/AESPID needs udpate.'; put _war = _count_spid = ; end; AESPID = strip(tranwrd(scan(hospid,1,'/'),'HO-','')); output; AESPID = strip(tranwrd(scan(hospid,2,'/'),'HO-','')); output; AESPID = strip(tranwrd(scan(hospid,3,'/'),'HO-','')); output; AESPID = strip(tranwrd(scan(hospid,4,'/'),'HO-','')); output; AESPID = strip(tranwrd(scan(hospid,5,'/'),'HO-','')); output; AESPID = strip(tranwrd(scan(hospid,6,'/'),'HO-','')); output; AESPID = strip(tranwrd(scan(hospid,7,'/'),'HO-','')); output; AESPID = strip(tranwrd(scan(hospid,8,'/'),'HO-','')); output; AESPID = strip(tranwrd(scan(hospid,9,'/'),'HO-','')); output; AESPID = strip(tranwrd(scan(hospid,10,'/'),'HO-','')); output; run; proc sort tagsort data=ho_icu2; by usubjid aespid; where ^missing(aespid); run; proc sort tagsort data=ds_all out=ds_eos; by usubjid subjid descending dsseq; where dsdecod in ('SAE' 'AE' 'ADVERSE EVENT' 'SERIOUS ADVERSE EVENT') and DSSCAT='END OF STUDY'; run; proc sort tagsort data=ds_eos nodupkey; by usubjid subjid; run; **INSERT CODE TO GENERATE DATASET**; proc sort tagsort data=ae_all; by usubjid aespid; run; data ae_ho; length aespid $200.; merge ae_all(in=a) ho_icu2(where=(_hoterm_icu='ICU') rename=(hodecod=_hoterm_icu)); by usubjid aespid; if a; array _aesc $1 AESCONG; AETERM = compbl(strip(tranwrd(AETERM,'0920'x,'2020'x))); run; proc sort tagsort data=ae_ho; by usubjid subjid; run; data ae_adsl; length _war $2000.; merge ae_ho(in=a where=(AETERM^='')) adb.adsl(in=b keep=USUBJID subjid &adslvar.) ds_eos(in=c keep=usubjid subjid aespidx); by usubjid subjid; if a and b; **AEDISFL; _count = count(aespidx,','); if _count>2 then do; _war = 'Put Aler'||'t_R: AEDISFL needs udpate.'; put _war = subjid= _count = ; end; _aespidx1 = strip(scan(aespidx,1,',')); _aespidx2 = strip(scan(aespidx,2,',')); _aespidx3 = strip(scan(aespidx,3,',')); if 'AE-'||aegrpid=_aespidx1 or 'AE-'||aegrpid=_aespidx2 or 'AE-'||aegrpid=_aespidx3 then AEDISFL = 'Y'; if upcase(aeout)='FA'||'TAL' or index(upcase(aeterm),'DEATH') then AEDISFL = 'Y'; run; data ae_date; length ASTAGE $30 AEHSTDTC AEHENDTC ICUAD $20 AEDOSERF $50 AESPID $&lenspid.; label AESPID="&labspid."; set ae_adsl(rename=(aespid=ori_aespid)); AESPID = ori_aespid; * Hospital Admission/Discharge Date; AEHSTDTC = AEHOSPST; AEHENDTC = AEHOSPEN; * Admitted to ICU? ; ICUAD = hooccur; ICUDAY = input(compress(hodur,,'kd'),??best.); * AE Start Date Time; if TRTSDT>. then __rfxstdtc = put(TRTSDT,yymmdd10.); __aeendtc = aeendtc; %imp_atdt(sten=st,vardtc=aestdtc,trtsdtc=__rfxstdtc,dendtc=__aeendtc,oriendtc=aestdtc); %ISO2SAS(isodate=imp_aestdtc, datec=_aestdtc, daten=ASTDT, timec=_asttm); if index(_asttm,'--') then _asttm=''; if imp_ori_st___rfxstdtc='Yes' then do; _war='Put Aler'||'t_C: ASTTM will be imputed as tr01sdtm. '; put _war subjid= aestdtc= tr01sdtm= _asttm=; ASTTM = timepart(tr01sdtm); if input(_asttm,time5.)^=asttm then ASTTMF = 'H'; end; if ^missing(_asttm) and ^missing(ASTDT) then ASTDTM = input(compress(put(ASTDT,date9.)||':'||_asttm),datetime20.); if ^missing(_asttm) then ASTTM = input(_asttm,time5.); * AE End Date Time; %ISO2SAS(isodate=aeendtc, datec=_aendtc, daten=AENDT, timec=_aentm); if index(_aentm,'--') then _aentm = ''; if ^missing(_aentm) and ^missing(AENDT) then AENDTM = input(compress(put(AENDT,date9.)||':'||_aentm),datetime20.); if ^missing(_aentm) then AENTM = input(_aentm,time5.); if ASTDT>AENDT>. then do; *if ASTDTF='D' and month(ASTDT)^=month(AENDT) and year(ASTDT)=year(AENDT) then ASTDTF = 'M'; *else if ASTDTF^='' and year(ASTDT)^=year(AENDT) then ASTDTF = 'Y'; ASTDT = AENDT; if ^missing(ASTTM) then ASTTM = AENTM; if ^missing(ASTDTM) then ASTDTM = AENDTM; end; %if %index("&ADAM_SPEC.",DSMB) %then %do; * Period (C); if (astdt=. and AENDT>=OLD1DT>.) or ASTDTM>=OLD1DTM>. or ((ASTDTM=. or OLD1DTM=.) and ASTDT>=OLD1DT>.) then APERIODC = "Open Label"; else if (ASTDT=. and AENDT<=OLD1DT) or OLD1DTM=. or .0 and .0 and .TR01EDT+27 and TR01EDT>.) or (ASTDT>TR02EDT+27 and TR02EDT>.) then ASTAGE = 'Follow-Up stage'; if ASTAGE='Vaccination stage' then ASTAGEN = 1; else if ASTAGE='Follow-Up stage' then ASTAGEN = 2; * Most Recent Dose Reference; %xxdoserf(xx=AE,adt=ASTDT,adtm=ASTDTM,rddy=RDSTDY,tim=YES); MDOSREF = out_AEDOSERF; MRDSTDY = AERDSTDY; AEDOSERF = ''; out_AEDOSERF = ''; if MDOSREF^='' and (.. and MRDSTDY>MRDENDY>. then MRDSTDY = MRDENDY; %if %index("&ADAM_SPEC.",DSMB) %then %do; AERDSTDY = MRDSTDY; %end; * Relative Start Time (Mins) from Most Recent Dose; if MDOSREF='Vaccination 1' and cmiss(ASTDTM,TR01SDTM)=0 then RSTFRD = (ASTDTM - TR01SDTM)/60; else if MDOSREF='Vaccination 2' and cmiss(ASTDTM,DOS2DTM)=0 then RSTFRD = (ASTDTM - DOS2DTM)/60; else if MDOSREF='OL Vaccination 1' and cmiss(ASTDTM,TR02SDTM)=0 then RSTFRD = (ASTDTM - TR02SDTM)/60; else if MDOSREF='OL Vaccination 2' and cmiss(ASTDTM,OLDO2DTM)=0 then RSTFRD = (ASTDTM - OLDO2DTM)/60; * Relative Day; %caldy(stdt=ASTDT,endt=TR01SDT,outdy=ASTDY); format ASTDTM AENDTM datetime20. ASTTM AENTM time5.; run; data ae_flag; length ASEV ATOXGR AREL AEMAFL $20 ; set ae_date(rename=(MAAEFL=_AEMAFL)); * D28FL - AE Through 28 Days Analysis Flag; if 0<=MRDSTDY<=28 then D28FL = 'Y'; else do; D28FL = ''; if ^missing(tr01sdt) then _tr01sdt_28 = tr01sdt + 28; if ^missing(dose2dt) then _dose2dt_28 = dose2dt + 28; format _tr01sdt_28 _dose2dt_28 date9.; end; * Treatment Emergent Analysis Flag; if .=3 then do; TOXGGR1 = '>=3'; TOXGGR1N = 2; end; else if .=4 then ASEV = strip(ATOXGR); else if cmiss(ATOXGR,AESEV)<2 and ^missing(AESEV) then ASEV = strip(ATOXGR)||'/'||propcase(AESEV); else if cmiss(ATOXGR,AESEV)<2 then ASEV = strip(ATOXGR); if ASEV='Grade 1/Mild' then ASEVN = 1; else if ASEV='Grade 2/Moderate' then ASEVN = 2; else if ASEV='Grade 3/Severe' then ASEVN = 3; else if ASEV='Grade 4' then ASEVN = 4; else if ASEV='Grade 5' then ASEVN = 5; else if ^missing(AESEV) then do; _war = 'Put Aler'||'t_A: ASEV/ASEVN needs update. '; put _war SUBJID= AESEV= AETOXGR= ATOXGR= ASEV= ASEVN= ; end; run; *********************************************************************************; *********************************************************************************; ** IMPORT.EOI - Hypertension; %macro create_import(imp=,condi=,var=,aedecod=,kep1=); data &imp._&var.; length aedecod $&lencod.; set import.&imp.(rename=(&aedecod.=_aedecod)); where &condi.; aedecod = strip(_aedecod); %if &kep1.^= %then %do; &kep1._&var. = upcase(&kep1.); ori_&kep1._&var. = &kep1.; %end; run; proc sort tagsort data=&imp._&var.(keep=aedecod %if &kep1.^= %then %do; &kep1._&var. ori_&kep1._&var. %end;) nodupkey; by aedecod %if &kep1.^= %then %do; &kep1._&var. %end;; run; %mend create_import; %create_import(imp=smq,condi=SMQNAME='ANAPHYLACTIC REACTION',var=smq1,aedecod=pt,kep1=SCOPE); %create_import(imp=smq,condi=SMQNAME='ANGIOEDEMA',var=smq2,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='ARTHRITIS',var=smq3,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='CONVULSIONS',var=smq4,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='DEMYELINATION',var=smq5,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='HYPERSENSITIVITY',var=smq6,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='PERIPHERAL NEUROPATHY',var=smq7,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='VASCULITIS',var=smq8,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='CENTRAL NERVOUS SYSTEM VASCULAR DISORDERS',var=smq9,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='EMBOLIC AND THROMBOTIC EVENTS',var=smq10,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='HEARING AND VESTIBULAR DISORDERS',var=smq11,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='THROMBOPHLEBITIS',var=smq12,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='HAEMATOPOIETIC CYTOPENIAS',var=smq13,aedecod=pt,kep1=scope); %create_import(imp=smq,condi=SMQNAME='CARDIOMYOPATHY',var=smq14,aedecod=pt,kep1=scope); %create_import(imp=cmq,condi=CMQNAME='DERMAL FILLER REACTION POST VACCINATION',var=cmq2,aedecod=pt,kep1=); %create_import(imp=symp,condi=CECAT^='',var=symp,aedecod=cedecod,kep1=ceterm); %create_import(imp=smq,condi=SMQNAME='ANAPHYLACTIC REACTION' and SCOPE='Narrow',var=narrow,aedecod=pt,kep1=SCOPE); %create_import(imp=smq,condi=SMQNAME='ANAPHYLACTIC REACTION' and CATEGORY='A',var=smqa,aedecod=pt,kep1=CATEGORY); %create_import(imp=smq,condi=SMQNAME='ANAPHYLACTIC REACTION' and CATEGORY='B',var=smqb,aedecod=pt,kep1=CATEGORY); %create_import(imp=smq,condi=SMQNAME='ANAPHYLACTIC REACTION' and CATEGORY='C',var=smqc,aedecod=pt,kep1=CATEGORY); %create_import(imp=smq,condi=SMQNAME='ANAPHYLACTIC REACTION' and CATEGORY='D',var=smqd,aedecod=pt,kep1=CATEGORY); %create_import(imp=aesi,condi=INCLUDE_IN_REQUESTED_IDMC_PT_TAB^='',var=term,aedecod=DICTIONARY_DERIVED_TERM,kep1=); %create_import(imp=aeneu,condi=CODE^='',var=aeneu,aedecod=aedecod,kep1=); ** CQ01NAM; data imp_cq01nam; set import.cmq; where CMQNAME='AUTOIMMUNE'; AEPTCD = input(PTCODE,best.); run; proc sort tagsort data=imp_cq01nam nodupkey; by aeptcd; run; proc sort tagsort data=ae_flag; by aeptcd; run; data ae_cq01nam; merge ae_flag(in=a) imp_cq01nam(in=cmq); by aeptcd; if a; if cmq then do; CQ01NAM = 'Autoimmune'; CQ01FL = 'Y'; end; else call missing(CQ01NAM,CQ01FL); run; proc sort tagsort data=ae_cq01nam; by aedecod; run; data hyper; merge ae_cq01nam(in=a) smq_smq1(in=smq1) cmq_cmq2(in=cmq2) smq_smq2(in=smq2) smq_smq3(in=smq3) smq_smq4(in=smq4) smq_smq5(in=smq5) smq_smq6(in=smq6) smq_smq7(in=smq7) smq_smq8(in=smq8) smq_smq9(in=smq9) smq_smq10(in=smq10) smq_smq11(in=smq11) smq_smq12(in=smq12) smq_smq13(in=smq13) smq_smq14(in=smq14) symp_symp(in=symp) smq_narrow(in=smqnarrow) smq_smqa(in=smqa) smq_smqb(in=smqb) smq_smqc(in=smqc) smq_smqd(in=smqd) aesi_term(in=aesi) aeneu_aeneu(in=aeneu); by aedecod; if a; array _smq(10) $100 SMQ01NAM SMQ02NAM SMQ03NAM SMQ04NAM SMQ05NAM SMQ06NAM SMQ07NAM SMQ08NAM SMQ09NAM CQ02NAM; array _anl(10) $1 SMQ01FL SMQ02FL SMQ03FL SMQ04FL SMQ05FL SMQ06FL SMQ07FL SMQ08FL SMQ09FL CQ02FL; if cmq2 then do; CQ02NAM = 'Dermal Filler Reaction Post Vaccination'; CQ02FL = 'Y'; end; else call missing(CQ02NAM,CQ02FL); if AELLT in ("Bell's palsy" "Palsy Bells" "Facial palsy" "Facial paralysis") then CQ03NAM = "Bell's Palsy"; else CQ03NAM = ''; if CQ03NAM^='' then CQ03FL = 'Y'; else CQ03FL = ''; if symp then do; ARTERM = ori_ceterm_symp; ANL02FL = 'Y'; end; else call missing(ARTERM,ANL02FL); if symp and removefl=:'Y' then delete; if smq1 then do; SMQ01SC = scope_smq1; SMQ01NAM = 'Anaphylactic Reaction'; SMQ01FL = 'Y'; end; else call missing(SMQ01SC,SMQ01NAM,SMQ01FL); if smq2 then do; SMQ02SC = scope_smq2; SMQ02NAM = 'Angioedema'; if SMQ02SC='NARROW' then SMQ02FL = 'Y'; end; else call missing(SMQ02SC,SMQ02NAM,SMQ02FL); if smq3 then do; SMQ03SC = scope_smq3; SMQ03NAM = 'Arthritis'; if SMQ03SC='NARROW' then SMQ03FL = 'Y'; end; else call missing(SMQ03SC,SMQ03NAM,SMQ03FL); if smq4 then do; SMQ04SC = scope_smq4; SMQ04NAM = 'Convulsions'; if SMQ04SC='NARROW' then SMQ04FL = 'Y'; end; else call missing(SMQ04SC,SMQ04NAM,SMQ04FL); if smq5 then do; SMQ05SC = scope_smq5; SMQ05NAM = 'Demyelinating Disease of Central Nervous System'; if SMQ05SC='NARROW' then SMQ05FL = 'Y'; end; else call missing(SMQ05SC,SMQ05NAM,SMQ05FL); if smq6 then do; SMQ06SC = scope_smq6; SMQ06NAM = 'Hypersensitivity'; if SMQ06SC='NARROW' then SMQ06FL = 'Y'; end; else call missing(SMQ06SC,SMQ06NAM,SMQ06FL); if smq7 then do; SMQ07SC = scope_smq7; SMQ07NAM = 'Peripheral Neuropathy'; if SMQ07SC='NARROW' then SMQ07FL = 'Y'; end; else call missing(SMQ07SC,SMQ07NAM,SMQ07FL); if smq8 then do; SMQ08SC = scope_smq8; SMQ08NAM = 'Vasculitis'; if SMQ08SC='NARROW' then SMQ08FL = 'Y'; end; else call missing(SMQ08SC,SMQ08NAM,SMQ08FL); if smq9 then do; SMQ09SC = scope_smq9; SMQ09NAM = 'Central Nervous System Vascular Disorders'; if SMQ09SC='NARROW' then SMQ09FL = 'Y'; end; else call missing(SMQ09SC,SMQ09NAM,SMQ09FL); if smq10 then do; SMQ10SC = scope_smq10; SMQ10NAM = 'Embolic and Thrombotic Events'; if SMQ10SC='NARROW' then SMQ10FL = 'Y'; end; else call missing(SMQ10SC,SMQ10NAM,SMQ10FL); if smq11 then do; SMQ11SC = scope_smq11; SMQ11NAM = 'Hearing and Vestibular Disorders'; if SMQ11SC='NARROW' then SMQ11FL = 'Y'; end; else call missing(SMQ11SC,SMQ11NAM,SMQ11FL); if smq12 then do; SMQ12SC = scope_smq12; SMQ12NAM = 'Thrombophlebitis'; if SMQ12SC='NARROW' then SMQ12FL = 'Y'; end; else call missing(SMQ12SC,SMQ12NAM,SMQ12FL); if smq13 then do; SMQ13SC = scope_smq13; SMQ13NAM = 'Haematopoietic Cytopenias'; if SMQ13SC='NARROW' then SMQ13FL = 'Y'; end; else call missing(SMQ13SC,SMQ13NAM,SMQ13FL); if smq14 then do; SMQ14SC = scope_smq14; SMQ14NAM = 'Cardiomyopathy'; if SMQ14SC='NARROW' then SMQ14FL = 'Y'; end; else call missing(SMQ14SC,SMQ14NAM,SMQ14FL); if aesi or aeneu then AENEUFL = 'Y'; ** ANL01FL; if ARTERM in ('Pain' 'Erythema' 'Swelling' 'Underarm Gland Swelling or Tenderness') and MRDSTDY>=8 then ANL01FL = 'Y'; if cmiss(SMQ01FL,SMQ02FL,SMQ03FL,SMQ04FL,SMQ05FL,SMQ06FL,SMQ07FL,SMQ08FL,SMQ09FL, SMQ10FL,SMQ11FL,SMQ12FL,SMQ13FL,SMQ14FL)<14 or ARTERM^='' then _flagfl='Y'; *** Analysis Duration Start Date; ADURSDT = astdt; if TRTEMFL='Y' and missing(astdt) then ADURSDT = TR01SDT; *** Analysis Duration End Date; ADUREDT = aendt; if missing(ADUREDT) and ^missing(aeendtc) and index(aeendtc,'-----')=0 then do; _war='Put Aler'||'t_P: ADUREDT needs udpate.'; put _war= aeendtc= aestdtc=; end; if missing(ADUREDT) and ^missing(ADURSDT) then do; if ASTDT>"&cutext."d then ADUREDT = EXTDT; else ADUREDT = CUTOFFDT; if ADUREDT>EOSDT>. then ADUREDT = EOSDT; end; format ADURSDT ADUREDT date9.; run; proc sort tagsort data=hyper; by usubjid subjid mdosref descending _flagfl aedecod adursdt aduredt; run; data retain_hyper; length first_aedecod $50; set hyper; by usubjid subjid mdosref descending _flagfl aedecod adursdt aduredt; retain retainsdt retainedt deldy; if _flagfl='Y' then do; lagsdt = lag(adursdt); lagedt = lag(aduredt); if first.aedecod then do; retainsdt = adursdt; retainedt = aduredt; deldy = 0; first_aedecod = 'First'; end; else if lagsdt<=adursdt<=lagedt or lagsdt<=aduredt<=lagedt then do; retainedt = max(retainedt,aduredt); first_aedecod = 'Overlapped'; end; else if adursdt<=retainedt+1 then do; retainedt = max(retainedt,aduredt); first_aedecod = 'Overlapped'; end; else do; deldy = sum(deldy,(adursdt - retainedt - 1)); retainedt = max(retainedt,aduredt); end; if last.aedecod then retainedt = max(retainedt,aduredt); end; else retainedt = .; if ^missing(aduredt) and ^missing(adursdt) then adurn_int = retainedt-retainsdt+1-deldy; format lag: retain: adursdt aduredt date9.; run; proc sort tagsort data=retain_hyper out=retain_adurn; by usubjid subjid mdosref aedecod descending adurn_int adursdt descending aeseq; run; data retain_adurn; set retain_adurn; by usubjid subjid mdosref aedecod descending adurn_int adursdt descending aeseq; retain retain_adurn; if first.aedecod then retain_adurn = adurn_int; run; proc sort tagsort data=retain_adurn; by usubjid subjid mdosref aedecod descending retain_adurn descending ADURSDT descending aeseq; run; data adae_adurn; set retain_adurn; by usubjid subjid mdosref aedecod descending retain_adurn descending ADURSDT descending aeseq; if last.aedecod and ^missing(ADURSDT) and ^missing(ADUREDT) and ^missing(mdosref) then pre_adurn = retain_adurn; run; proc sort tagsort data=adae_adurn; by usubjid subjid mdosref aedecod descending pre_adurn; run; data adae_adurn; set adae_adurn; by usubjid subjid mdosref aedecod descending pre_adurn; retain _ADURN; if first.aedecod and ^missing(mdosref) and ^missing(aedecod) then _ADURN = pre_adurn; else if first.aedecod then _ADURN = .; ADURN = _ADURN; if missing(_flagfl) then ADURN = .; if category_smqb^='' or category_smqc^='' then _smqbcfl=1; if category_smqb^='' or category_smqc^='' or category_smqd^='' then _smqdfl=1; run; proc sort data=adae_adurn; by usubjid _smqbcfl aestdtc;run; data category_b_and_c; set adae_adurn; by usubjid _smqbcfl aestdtc; lag_smqb = lag(category_smqb); lag_smqc = lag(category_smqc); lag_aestdtc = lag(aestdtc); lag_astdtm = lag(astdtm); if _smqbcfl=1 then do; if ^missing(astdtm) and ^missing(lag_astdtm) then _hour = (lag_astdtm-astdtm)/60*24; else if ^missing(aestdtc) and ^missing(lag_aestdtc) then do; _en = input(substr(aestdtc,1,10),yymmdd10.); _st = input(substr(lag_aestdtc,1,10),yymmdd10.); _hour = (_en-_st)*24; end; if not first.usubjid and ((^missing(lag_smqb) and ^missing(category_smqc)) or (^missing(lag_smqc) and ^missing(category_smqb))) and .. then APLREAS2 = "A term from Category B AND a term from Category C"; if max_b_or_c>. then APLREAS3 = "A term from Category D AND [a term from Category B OR a term from Category C]"; if cmiss(APLREAS1,APLREAS2,APLREAS3)<3 then APLREAS=catx('; ',APLREAS1,APLREAS2,APLREAS3); if ^missing(APLREAS) then APLFL = 'Y'; run; proc sort tagsort data=adae_aplreas; by usubjid MDOSREF ARTERM; run; ** FACE; data face; set trans.face; where facat='REACTOGENICITY' and fatptref^='' and fastresc^='NONE' and index(fastresc,'GRADE 0')=0 and fastat=''; if faobj in ('Erythema' 'Swelling') and fatestcd='OCCUR' then delete; if faobj in ('Erythema' 'Swelling') and fatestcd='LDIAM' and fastresu='mm' and fastresn<25 then delete; if fatptref='DOSE 1' then MDOSREF = 'Vaccination 1'; else if fatptref='DOSE 2' then MDOSREF = 'Vaccination 2'; ARTERM = faobj; run; proc sort tagsort data=face; by usubjid MDOSREF ARTERM descending fatptnum; run; proc sort tagsort data=face out=face_max nodupkey; by usubjid MDOSREF ARTERM; run; proc sort tagsort data=face out=face_7 nodupkey; by usubjid MDOSREF ARTERM; where fatptnum=7; run; ** FAAE; data faae; set trans.faae; where facat='REACTOGENICITY' and fatptref^='' and fastresc^='NONE' and index(fastresc,'GRADE 0')=0 and fastat=''; if faobj in ('Erythema' 'Swelling') and fatestcd='OCCUR' then delete; if faobj in ('Erythema' 'Swelling') and fatestcd='LDIAM' and fastresu='mm' and fastresn<25 then delete; if fatptref='DOSE 1' then MDOSREF = 'Vaccination 1'; else if fatptref='DOSE 2' then MDOSREF = 'Vaccination 2'; ARTERM = faobj; run; proc sort tagsort data=faae nodupkey; by usubjid MDOSREF ARTERM; run; data adae; merge adae_aplreas(in=a) face_7(in=b keep=usubjid MDOSREF ARTERM) face_max(in=c keep=usubjid MDOSREF ARTERM fatptnum) faae(in=d keep=usubjid MDOSREF ARTERM); by usubjid MDOSREF ARTERM; if a; if ARTERM^='' then AESOFL = 'Y'; else AESOFL = ''; ** ANL02FL; if ANL01FL='Y' and MRDSTDY=8 and b then ANL02FL = 'Y'; else ANL02FL = ''; ** ANL03FL; if ANL01FL='Y' and c and not d then ANL03FL = 'Y'; else ANL03FL = ' '; if ANL03FL='Y' and MRDSTDY=8 and fatptnum>=7 then ANL03FL = ''; ** ANL04FL; if ANL01FL='Y' and not c then ANL04FL = 'Y'; else ANL04FL = ' '; %if %index("&ADAM_SPEC.",DSMB) %then %do; AEMAAEFL = AEMAFL; AEICU = ICUAD; AEICUNUM = ICUDAY; %end; if ^missing(astdt) then do; adtm=astdtm; adt=astdt; end; else if ^missing(aendt) then do; adtm=aendtm; adt=aendt; end; drop &adslvar. subjid; run; **Generate final dataset by updating certain attributes. Optionally merge common variables & create sequence variable as needed**; %trta(dsname=&DSETNAME); %adam_dataset_update( ds=&DSETNAME, libin=work, libout=output, adsllib=adb, addcomvar=Y, addseq=, dropinfmt=Y, mapspecfile=&ADAM_SPEC, maploc=&ADAM_SPEC_LOC, debug=N ); **Generate Value Level Metadata values for the ad dataset**; %* dod_vlm( type=ADAM, selmems=&DSETNAME, excmems=, specloc=&ADAM_SPEC_LOC, specname=&ADAM_SPEC, debug=N ); **Generate Enhanced Controlled Terminology for the ad dataset**; %* dod_enhcd_ct( type=ADAM, selmems=&DSETNAME, excmems=, specloc=&ADAM_SPEC_LOC, specname=&ADAM_SPEC, map_ct_nm=, map_ct_loc=, debug=N );