*************************************************************************************************; * * CLIENT: ModernaTX, Inc. * PROTOCOL: mRNA-1273-P301 * * PURPOSE: Macros used for adam programming * * INPUT FILES: * OUTPUT FILES: * * USAGE NOTES: * *************************************************************************************************; * Copyright 2020 Pharmaceutical Product Development, Inc. * All Rights Reserved. *************************************************************************************************; options missing=''; * Derive TRTA(N); %put ; %macro trta(dsname=); %global DOSERF; %let DOSERF = ; proc sort data = adb.adsl out = adsl (keep = usubjid tr01sdtm dos2dtm tr01sdt dose2dt tr02sdtm tr02sdt oldo2dtm oldos2dt rename = ( tr01sdtm=_tr01sdtm dos2dtm=_dos2dtm tr01sdt =_tr01sdt dose2dt =_dose2dt tr02sdtm=_tr02sdtm tr02sdt=_tr02sdt oldo2dtm=_oldo2dtm oldos2dt=_oldos2dt) ); by usubjid; run; proc sort data= trans.EX out = EX_DOSE1 (keep = usubjid extrt exdose rename = ( extrt=extrt_dose1 exdose = exdose_dose1)) nodupkey; by usubjid exdose; where index(upcase(visit),'DAY 1 '); run; proc sort data= trans.EX out = EX_DOSE2 (keep = usubjid extrt exdose rename = ( extrt=extrt_dose2 exdose = exdose_dose2)) nodupkey; by usubjid; where index(upcase(visit),'DAY 29'); run; proc sort data= trans.EX out = EX_DOSE3 (keep = usubjid extrt exdose rename = ( extrt=extrt_dose3 exdose = exdose_dose3)) nodupkey; by usubjid exdose; where index(upcase(visit),'OL-D1'); run; proc sort data= trans.EX out = EX_DOSE4 (keep = usubjid extrt exdose rename = ( extrt=extrt_dose4 exdose = exdose_dose4)) nodupkey; by usubjid exdose; where index(upcase(visit),'OL-D29'); run; proc sort data = &dsname. ; by usubjid; run; proc sql noprint; select name into: DOSERF from dictionary.columns where upcase(libname)='WORK' and (index(upcase(name),'MDOSREF') > 0 or upcase(name)='ATPTREF' ) and upcase(memname) =upcase("&DSNAME.") ; quit; %if &DOSERF. ne %then %put Alert_I: Dose reference variable %sysfunc(strip(&DOSERF)) used to derive TRTA(N); %else %put Alert_I: Using analyis date to derive TRTA(N); data &dsname.; length TRTA _DOSE $50.; merge &dsname. (in=a) EX_DOSE1 EX_DOSE2 EX_DOSE3 EX_DOSE4 adsl; by usubjid; if a; label TRTA = "Actual Treatment" TRTAN = "Actual Treatment (N)"; %if &DOSERF. ne %Then %do; _DOSE = &DOSERF.; %end; %else %do; *Dose 1; if nmiss(_TR01sdtm , adtm, _dos2dtm)=0 and (_TR01sdtm<=adtm<_dos2dtm) then _DOSE = 'Vaccination 1'; else if nmiss(_TR01sdtm , adtm)=0 and (_TR01sdtm<=adtm) and _dos2dtm=. and (_tr02sdtm=. or .0) or (.<_dose2dt<=adt and _tr02sdt=. and cmiss(_dos2dtm,adtm)>0) then _DOSE = 'Vaccination 2'; end; *Dose 1 - Oplen Label; if extrt_dose3^='' then do; if (.<_tr02sdtm<=adtm<_oldo2dtm) or (.<_tr02sdtm<=adtm and _oldos2dt=.) or (.<_tr02sdtm<=adtm and _oldo2dtm=. and adt<_oldos2dt) then _DOSE = 'OL Vaccination 1'; else if (.<_tr02sdt<=adt<_oldos2dt and cmiss(_tr02sdtm,adtm)>0) or (.<_tr02sdt<=adt and _oldos2dt=. and cmiss(_tr02sdtm,adtm)>0) then _DOSE = 'OL Vaccination 1'; end; *Dose 2 - Oplen Label; if extrt_dose4^='' then do; if _tr02sdtm<=_oldo2dtm<=adtm and cmiss(_oldo2dtm,adtm)=0 then _DOSE = 'OL Vaccination 2'; else if _tr02sdt<=_oldos2dt<=adt and adt>. and cmiss(_oldo2dtm,adtm)>0 then _DOSE = 'OL Vaccination 2'; end; %end; *Dose 1; if _DOSE = 'Vaccination 1' then do; if upcase(extrt_dose1) = 'PLACEBO' then TRTA = 'Placebo'; else if index(upcase(extrt_dose1) ,'MRNA' ) > 0 and 0< exdose_dose1 then TRTA = 'mRNA-1273'; end; *Dose 2; if _DOSE = 'Vaccination 2' then do; if upcase(extrt_dose2) = 'PLACEBO' then TRTA = 'Placebo'; else if index(upcase(extrt_dose2) ,'MRNA' ) > 0 and 0< exdose_dose2 then TRTA = 'mRNA-1273'; end; *Dose 1 - Open Label; if _DOSE = 'OL Vaccination 1' then do; if upcase(extrt_dose3) = 'PLACEBO' then TRTA = 'Placebo'; else if index(upcase(extrt_dose3) ,'MRNA' ) > 0 and 0< exdose_dose3 then TRTA = 'mRNA-1273'; end; *Dose 2; if _DOSE = 'OL Vaccination 2' then do; if upcase(extrt_dose4) = 'PLACEBO' then TRTA = 'Placebo'; else if index(upcase(extrt_dose4) ,'MRNA' ) > 0 and 0< exdose_dose4 then TRTA = 'mRNA-1273'; end; if TRTA = 'Placebo' then TRTAN = 1; if TRTA = 'mRNA-1273' then TRTAN = 2; run; %CLN_CARRIAGE(libin=work,selmems=&DSETNAME,enhanced=Y,from='090d0a0cC2B0A0'x,to='20202020202020'x); %mend trta; * Derive ABLFL - Baseline Record Flag & AVISIT - Analysis Windows & CHG/PCHG; %put ; %macro ablfl(indst=,outdst=base_chg,seq=,basec=Y,avisit_type=,stresc=,tpt=,tptnum=,uns_blank=Y,addsortn=,illtpt=); data &indst._ablfl; set &indst.; visit=tranwrd(visit,'Convalescence','Illness'); if missing(visit) or index(visit,'Saf') or index(visit,'COV') then visit = 'Unsched '||visit; * _adtm; if ADTM>TR01SDTM>. then _adtmy = ADTM - TR01SDTM; else if cmiss(ADT,TR01SDT)=0 then _adtmy = input(compress(put(ADT,date9.)||':00:00'),datetime20.) - input(compress(put(TR01SDT,date9.)||':00:00'),datetime20.); else if index(upcase(visit),'ILLNESS')=0 then _adtmy = 99999999; %if &tpt.= %then %do; if _adtmy<=0 and ^missing(TR01SDT) then prefl='Y'; else if _adtmy>0 and ^missing(TR01SDT) then postfl='Y'; %end; %else %if &tpt.^= %then %do; if index(&tpt.,'POST') and adt=tr01sdt then postfl='Y'; else if (_adtmy<=0 and ^missing(TR01SDT)) then prefl='Y'; else if _adtmy>0 and ^missing(TR01SDT) then postfl='Y'; %end; if missing(tr01sdt) or missing(adt) then postfl = ''; if prefl='Y' then prefl_adt = adt; if prefl='Y' then prefl_adtm = adtm; %if %lowcase(&dsetname.)=adis %then %do; if prefl='Y' then pre_aval = AVAL; %end; _adtmy = abs(_adtmy); if .0 then _adtmy_num = abs(_adtmy)+visitnum; else _adtmy_num = abs(_adtmy); if adt>tr01sdt>. and index(visit,'Uns') and visitnum=. then _adtmy = 999; else if adt>tr01sdt>. then _adtmy = visitnum; * _avaln; if ^missing(&stresc.) then _avaln = 1; else _avaln = 0; if (index(upcase(visit),'ILLNESS') or index(visit,'Uns')) and (adt>tr01sdt>. or adt=.) then _avaln = 1; if ^missing(&stresc.) then _avaln2 = 1; else _avaln2 = 0; if index(visit,'Uns') then _illuns = 1; else if index(upcase(visit),'ILLNESS') or index(visit,'OL-D') then _illuns = 2; else _illuns = 0; array _alc(1) $ avalc; isstresn_ = 9; if prefl='Y' and index(upcase(visit),'ILLNESS')=0 then do; if upcase(avalc)='POSITIVE' then isstresn_ = 1; else if upcase(avalc)='NEGATIVE' then isstresn_ = 2; end; run; proc sort tagsort data=&indst._ablfl; by usubjid paramcd descending _avaln postfl descending prefl_adt %if %lowcase(&dsetname.)=adis %then %do; descending pre_aval %end; descending prefl_adtm descending _illuns visitnum; run; data &indst._old; set &indst._ablfl; by usubjid paramcd descending _avaln postfl descending prefl_adt %if %lowcase(&dsetname.)=adis %then %do; descending pre_aval %end; descending prefl_adtm descending _illuns visitnum; *** Retain: open Day 1; retain retain_opend1 retain_opendt; if index(upcase(visit),'OL-D1') and index(visit,'Uns')=0 then retain_opend1 = ADY; else if first.paramcd then retain_opend1 = .; if index(upcase(visit),'OL-D1') and index(visit,'Uns')=0 then retain_opendt = ADT; else if first.paramcd then retain_opendt = .; _opendy=ADT-retain_opendt; format retain_opendt date9.; run; proc sort tagsort data=&indst._old; by usubjid paramcd descending _avaln postfl descending prefl_adt descending prefl_adtm ADT &addsortn. _illuns _adtmy isstresn_ descending &tpt. _adtmy_num &tptnum. descending visitnum descending &seq.; run; data pre_&outdst.; length AVISIT $50; set &indst._old; by usubjid paramcd descending _avaln postfl descending prefl_adt descending prefl_adtm ADT &addsortn. _illuns _adtmy isstresn_ descending &tpt. _adtmy_num &tptnum. descending visitnum descending &seq.; * Baseline Record Flag; retain BASE baseline_adt baseline_adtm; if first.paramcd and _avaln=1 and prefl='Y' and ^missing(tr01sdt) then do; ABLFL = 'Y'; BASE = AVAL; AVISIT = 'Baseline'; baseline_adt = adt; baseline_adtm = adtm; %if &basec.=Y %then %do; retain basec; BASEC = AVALC; %end; end; else if first.paramcd then do; BASE = .; %if &basec.=Y %then %do; BASEC = ''; %end; end; if .1)) and index(upcase(visit),'ILLNESS') and _ill_set>0 then do; _ill_set = _ill_set - 1; end; end; else if first.paramcd then do; _ill_set = 0; _ill_dat = .; _ill_ady = .; end; if first.paramcd and last.paramcd and visit='Illness Visit Day 1' then _ill_set = 1; format _ill_dat baseline_adt scheill_date date9.; if ^missing(adt) and ^missing(_ill_dat) then adt_ill_adt = ADT-_ill_dat; if missing(AVISIT) and ADT>. then do; if upcase(visit)='VISIT 1 DAY 1' %if &tpt.^= %then %do; and index(upcase(&tpt.),'POST') %end; then AVISIT = 'Day 1'; else if visit='Illness Visit Day 1' then AVISIT = 'Illness Visit Day 1'; else if ADY>1 and index(upcase(visit),'ILLNESS') and index(visit,'Uns')=0 then AVISIT = 'Illness Visit Day '||strip(scan(visit,4)); else if ADY>1 and index(upcase(visit),'OL-D1') and index(visit,'Uns')=0 and index(visit,'Ill')=0 then AVISIT = 'Participant Decision Visit / OL-D1'; else if ADY>1 and index(upcase(visit),'OL-D29') and index(visit,'Uns')=0 and index(visit,'Ill')=0 then AVISIT = 'Open Label Day 29'; else if ADY>1 and index(upcase(visit),'OL-D57') and index(visit,'Uns')=0 and index(visit,'Ill')=0 then AVISIT = 'Open Label Day 57'; %if &avisit_type.=1 or &avisit_type.=2 %then %do; else if (index(upcase(visit),'ILLNESS') or index(visit,'Uns')) and ^missing(_ill_dat) and 2<=ADT-_ill_dat<=34 then AVISIT = 'Illness Visit Day 28'; else if ^missing(TR02SDT) and retain_opendt=ADT and ADT>. and index(visit,'Uns') then AVISIT = 'Participant Decision Visit / OL-D1'; else if ^missing(TR02SDT) and missing(OLDOS2DT) and index(visit,'Uns') and index(visit,'Ill')=0 and retain_opendt>. and ADT>. and 1<=ADT-retain_opendt<=42 then AVISIT = 'Open Label Day 29'; %if &avisit_type.=1 %then %do; else if ^missing(TR02SDT) and ^missing(OLDOS2DT) and index(visit,'Uns') and index(visit,'Ill')=0 and retain_opend1>. and ADT>. and 1<=ADT-retain_opendt<=42 then AVISIT = 'Open Label Day 29'; else if ^missing(TR02SDT) and ^missing(OLDOS2DT) and index(visit,'Uns') and index(visit,'Ill')=0 and retain_opend1>. and ADT>. and 42. and ADT>. and 1<=ADT-retain_opendt<=70 then AVISIT = 'Open Label Day 57'; %end; %end; %else %if &avisit_type.=3 %then %do; else if (index(upcase(visit),'ILLNESS') or (index(visit,'Uns') and index(visit,'Ill')=0)) and ^missing(_ill_dat) and 1<=ADT-_ill_dat<=2 then AVISIT = 'Illness Visit Day 3'; else if (index(upcase(visit),'ILLNESS') or (index(visit,'Uns') and index(visit,'Ill')=0)) and ^missing(_ill_dat) and 3<=ADT-_ill_dat<=4 then AVISIT = 'Illness Visit Day 5'; else if (index(upcase(visit),'ILLNESS') or (index(visit,'Uns') and index(visit,'Ill')=0)) and ^missing(_ill_dat) and 5<=ADT-_ill_dat<=6 then AVISIT = 'Illness Visit Day 7'; else if (index(upcase(visit),'ILLNESS') or (index(visit,'Uns') and index(visit,'Ill')=0)) and ^missing(_ill_dat) and 7<=ADT-_ill_dat<=10 then AVISIT = 'Illness Visit Day 9'; else if (index(upcase(visit),'ILLNESS') or (index(visit,'Uns') and index(visit,'Ill')=0)) and ^missing(_ill_dat) and 11<=ADT-_ill_dat<=16 then AVISIT = 'Illness Visit Day 14'; else if (index(upcase(visit),'ILLNESS') or (index(visit,'Uns') and index(visit,'Ill')=0)) and ^missing(_ill_dat) and 17<=ADT-_ill_dat<=23 then AVISIT = 'Illness Visit Day 21'; else if (index(upcase(visit),'ILLNESS') or (index(visit,'Uns') and index(visit,'Ill')=0)) and ^missing(_ill_dat) and 24<=ADT-_ill_dat<=34 then AVISIT = 'Illness Visit Day 28'; %if &illtpt.^= %then %do; else if (index(upcase(visit),'ILLNESS') and index(visit,'Uns')) and missing(scheill_date) and index(&illtpt.,'Day') then AVISIT = 'Illness Visit '||strip(&illtpt.); %end; %end; else if ADY>1 and ori_visit='Illness Visit Day 3 - Day 21' and missing(_ill_dat) then AVISIT = 'Illness Visit'; else if ADY>1 and index(visit,'Illness') then AVISIT = 'Illness Visit Day '||strip(scan(visit,4,'')); else if postfl='Y' and (index(visit,'Uns') or index(visit,'Safe') or index(upcase(visit),'ILLNESS')) then do; %if &avisit_type.=1 %then %do; if ADY=1 and (ADT>baseline_adt or (ADT=baseline_adt and (ADTM>baseline_adtm or cmiss(adtm,baseline_adtm)>0))) then AVISIT='Day 1'; else if 2<=ADY<=43 then AVISIT = 'Day 29'; else if 431 and postfl='Y' and index(upcase(visit),'DAY') then AVISIT = 'Day '||scan(visit,4); end; if missing(ABLFL) and adt=_ill_dat and adt>. and ^missing(scheill_update) and index(visit,'Uns') then AVISIT = 'Illness Visit Day 1'; run; proc sort data=pre_&outdst.; by usubjid paramcd descending _avaln postfl adt &addsortn. _adtmy descending &tpt. _adtmy_num &tptnum. descending &seq.; run; data pre_&outdst.; set pre_&outdst.; by usubjid paramcd descending _avaln postfl adt &addsortn. _adtmy descending &tpt. _adtmy_num &tptnum. descending &seq.; * AVISIT - Analysis Visit; if AVISIT='Illness Visit Day 1' then AVISITN = 101; else if AVISIT='Illness Visit Day 3' then AVISITN = 103; else if AVISIT='Illness Visit Day 5' then AVISITN = 105; else if AVISIT='Illness Visit Day 7' then AVISITN = 107; else if AVISIT='Illness Visit Day 9' then AVISITN = 109; else if AVISIT='Illness Visit Day 14' then AVISITN = 114; else if AVISIT='Illness Visit Day 21' then AVISITN = 121; else if AVISIT='Illness Visit Day 28' then AVISITN = 128; else if index(avisit,'Illness') then AVISITN = 100*_ill_set+1; else if missing(avisit) and postfl='Y' and (index(visit,'Uns') or missing(visit) or index(visit,'Safe')) then do; %if &avisit_type.=1 %then %do; if ADY=1 and (ADT>baseline_adt or (ADT=baseline_adt and (ADTM>baseline_adtm or cmiss(adtm,baseline_adtm)>0))) then AVISIT='Day 1'; else if 2<=ADY<=43 then AVISIT = 'Day 29'; else if 431 and baseline_adt>=adt>. then do; _war='Put Aler'||'t_R: check AVISIT when VISIT='||strip(visit)||'. '; put _war subjid= adt= adtm=; put baseline_adt = baseline_adtm=; end; end; * AVISITN - Analysis Visit (N); if AVISIT='Baseline' then AVISITN = 1; else if AVISIT='Day 1' then AVISITN = 2; else if AVISIT='Day 29' then AVISITN = 3; else if AVISIT='Day 57' then AVISITN = 4; else if AVISIT='Day 209' then AVISITN = 6; else if AVISIT='Day 394' then AVISITN = 7; else if AVISIT='Day 759' then AVISITN = 8; else if AVISIT='Participant Decision Visit / OL-D1' then AVISITN = 10; else if AVISIT='Open Label Day 29' then AVISITN = 11; else if AVISIT='Open Label Day 57' then AVISITN = 12; %if &avisit_type.=1 %then %do; if AVISITN not in (1 2 3 4 5 6 7 8 10 11 12 101 128) and avisitn<100 then call missing(avisit,avisitn); %end; %if &avisit_type.=2 %then %do; if AVISITN not in (1 3 4 6 7 8 10 11 12 101 128) and avisitn<100 then call missing(avisit,avisitn); %end; %if &avisit_type.=3 %then %do; if AVISITN not in (1 3 10) and avisitn<100 then call missing(avisit,avisitn); %end; run; proc sort tagsort data=pre_&outdst.; by usubjid paramcd descending _avaln postfl ADT descending _ill_ady; run; data pre2_&outdst.; set pre_&outdst.; by usubjid paramcd descending _avaln postfl ADT descending _ill_ady; retain retain_ill_ady; if ^missing(_ill_ady) then retain_ill_ady = _ill_ady; else if first.paramcd then retain_ill_ady = .; * Analysis Window Valid Relative Range; if _ill_set>1 and index(avisit,'Illness') and scan(avisit,3)='Day' and ^missing(scheill_day1) then do; AVISITN = 100*(_ill_set-1) + AVISITN; AVISIT = 'Illness Visit '||strip(put(_ill_set,best.))||' Day '||scan(avisit,4); relative_range='relative_range'; end; length AWRANGE $200; avisit_space = strip(avisit)||' '; if index(avisit,'Illness') and index(avisit_space,'Day 1 ') then AWRANGE = AVISIT; %if &avisit_type.=1 %then %do; else if index(avisit,'Illness') then AWRANGE = substr(avisit,1,lengthn(avisit)-2)||'2 - '||substr(avisit,1,lengthn(avisit)-2)||'35'; else if AVISIT='Baseline' then AWRANGE = '<=1 Pre-dose'; else if AVISIT='Day 1' then AWRANGE = 'Day 1 Post-dose'; else if AVISIT='Day 29' then AWRANGE = 'Day 2 - Day 43'; else if AVISIT='Day 57' then AWRANGE = 'Day 44 - Day 133'; else if AVISIT='Day 209' then AWRANGE = 'Day 134 - Day 301'; else if AVISIT='Day 394' then AWRANGE = 'Day 302 - Day 576'; else if AVISIT='Day 759' then AWRANGE = 'Day 577 - Day 773'; else if AVISITN=10 then AWRANGE = 'Participant Decision Visit / OL-D1'; else if AVISITN=11 then AWRANGE = 'Day 2 - Day 43 Relative to Participant Decision Visit / OL-D1'; else if AVISITN=12 then AWRANGE = 'Day 2 - Day 71 Relative to Participant Decision Visit / OL-D1'; %end; %else %if &avisit_type.=2 %then %do; else if index(avisit,'Illness') then AWRANGE = substr(avisit,1,lengthn(avisit)-2)||'3 - '||substr(avisit,1,lengthn(avisit)-2)||'35'; else if AVISIT='Baseline' then AWRANGE = '<=1 Pre-dose'; else if AVISIT='Day 29' then AWRANGE = 'Day 2 - Day 43 Pre-second-dose'; else if AVISIT='Day 57' then AWRANGE = 'Day 44 - Day 133'; else if AVISIT='Day 209' then AWRANGE = 'Day 134 - Day 301'; else if AVISIT='Day 394' then AWRANGE = 'Day 302 - Day 576'; else if AVISIT='Day 759' then AWRANGE = 'Day 577 - Day 773'; else if AVISITN=10 then AWRANGE = 'Participant Decision Visit / OL-D1'; else if AVISITN=11 then AWRANGE = 'Day 2 - Day 43 Relative to Participant Decision Visit / OL-D1'; else if AVISITN=12 then AWRANGE = 'Day 2 - Day 71 Relative to Participant Decision Visit / OL-D1'; %end; %else %if &avisit_type.=3 %then %do; else if index(avisit,'Illness') and index(avisit_space,'Day 3 ') then AWRANGE = substr(avisit,1,lengthn(avisit)-2)||' 2 - '||substr(avisit,1,lengthn(avisit)-2)||' 3'; else if index(avisit,'Illness') and index(avisit_space,'Day 5 ') then AWRANGE = substr(avisit,1,lengthn(avisit)-2)||' 4 - '||substr(avisit,1,lengthn(avisit)-2)||' 5'; else if index(avisit,'Illness') and index(avisit_space,'Day 7 ') then AWRANGE = substr(avisit,1,lengthn(avisit)-2)||' 6 - '||substr(avisit,1,lengthn(avisit)-2)||' 7'; else if index(avisit,'Illness') and index(avisit_space,'Day 9 ') then AWRANGE = substr(avisit,1,lengthn(avisit)-2)||' 8 - '||substr(avisit,1,lengthn(avisit)-2)||'11'; else if index(avisit,'Illness') and index(avisit_space,'Day 14 ') then AWRANGE = substr(avisit,1,lengthn(avisit)-2)||'12 - '||substr(avisit,1,lengthn(avisit)-2)||'17'; else if index(avisit,'Illness') and index(avisit_space,'Day 21 ') then AWRANGE = substr(avisit,1,lengthn(avisit)-2)||'18 - '||substr(avisit,1,lengthn(avisit)-2)||'24'; else if index(avisit,'Illness') and index(avisit_space,'Day 28 ') then AWRANGE = substr(avisit,1,lengthn(avisit)-2)||'25 - '||substr(avisit,1,lengthn(avisit)-2)||'35'; else if AVISIT='Baseline' then AWRANGE = '<=1 Pre-dose'; else if AVISIT='Day 29' then AWRANGE = 'Day 2 - Day 36'; else if AVISITN=10 then AWRANGE = 'Participant Decision Visit / OL-D1'; %end; AWRANGE = tranwrd(tranwrd(tranwrd(AWRANGE,'Day1','Day 1'),'Day2','Day 2'),'Day3','Day 3'); * Analysis Window Target; if avisitn=101 and ^missing(retain_ill_ady) then AWTARGET = retain_ill_ady; %if &avisit_type.=1 or &avisit_type.=2 %then %do; else if index(AWRANGE,'Illness') and index(avisit,'Day 1 ') then AWTARGET = retain_ill_ady; else if index(AWRANGE,'Illness') and index(AWRANGE,'Day 3') and retain_ill_ady>. then AWTARGET = retain_ill_ady+27; %end; %else %if &avisit_type.=3 %then %do; else if index(AWRANGE,'Illness') and index(avisit,'Day 1 ') then AWTARGET = retain_ill_ady; else if index(avisit,'Illness') and index(avisit_space,'Day 3 ') and retain_ill_ady>. then AWTARGET = retain_ill_ady+2; else if index(avisit,'Illness') and index(avisit_space,'Day 5 ') and retain_ill_ady>. then AWTARGET = retain_ill_ady+4; else if index(avisit,'Illness') and index(avisit_space,'Day 7 ') and retain_ill_ady>. then AWTARGET = retain_ill_ady+6; else if index(avisit,'Illness') and index(avisit_space,'Day 9 ') and retain_ill_ady>. then AWTARGET = retain_ill_ady+8; else if index(avisit,'Illness') and index(avisit_space,'Day 14 ') and retain_ill_ady>. then AWTARGET = retain_ill_ady+13; else if index(avisit,'Illness') and index(avisit_space,'Day 21 ') and retain_ill_ady>. then AWTARGET = retain_ill_ady+20; else if index(avisit,'Illness') and index(avisit_space,'Day 28 ') and retain_ill_ady>. then AWTARGET = retain_ill_ady+27; %end; else if AVISIT='Baseline' then AWTARGET = 1; else if AVISIT='Day 1' then AWTARGET = 1; else if AVISIT='Day 29' then AWTARGET = 29; else if AVISIT='Day 57' then AWTARGET = 57; else if AVISIT='Day 119' then AWTARGET = 119; else if AVISIT='Day 209' then AWTARGET = 209; else if AVISIT='Day 394' then AWTARGET = 394; else if AVISIT='Day 759' then AWTARGET = 759; else if AVISITN=10 then AWTARGET = retain_opend1; else if AVISITN=11 and retain_opend1>. then AWTARGET = retain_opend1 + 28; else if AVISITN=12 and retain_opend1>. then AWTARGET = retain_opend1 + 56; * Analysis Window Diff from Target; if cmiss(AWTARGET,ADY)=0 then AWTDIFF = abs(ADY - AWTARGET); if cmiss(AWTARGET,ADY)=0 then AWU = 'DAYS'; if postfl='Y' and (index(visit,'Uns') or missing(visit) or index(visit,'Safe')) then do; _uns=1; _awtdiff=awtdiff; end; else if postfl='Y' then do; _uns=0; _awtdiff=0; end; else _awtdiff=99999999; run; proc sort tagsort data=pre2_&outdst. out=&outdst.; by usubjid paramcd avisitn ADY _uns; run; %if &uns_blank.=Y %then %do; data &outdst.; set &outdst.; by usubjid paramcd avisitn ADY _uns; retain _retain_ady _retain_avisitn; if _uns=0 or (first.paramcd and index(visit,'999')=0) then do; _retain_ady = ady; _retain_avisitn = avisitn; end; if _uns=1 and _retain_ady>=ady>. and avisitn<100 and avisitn>_retain_avisitn and _retain_avisitn>. and avisitn>. then do; AWRANGE = ''; AWTARGET = .; AWTDIFF = .; AVISIT = ''; AVISITN = .; _awtdiff = 99999999; _avaln = 0; end; run; %end; %if &addsortn.=addsortn %then %do; data &outdst.; set &outdst.; derived_avisit = avisit; visit = ori_visit; if index(avisit,'Illness') then do; if 100<=avisitn<200 then do; avisitn = 100; avisit = scan(avisit,1)||' '||scan(avisit,2); end; else if avisitn>200 then do; avisitn = 100*input(compress(scan(avisit,3)),best.); avisit = scan(avisit,1)||' '||scan(avisit,2)||' '||scan(avisit,3); end; end; run; %end; * Analysis Flag 01; proc sort tagsort data=&outdst. out=anl01fl; by usubjid paramcd avisitn descending postfl descending _avaln descending _avaln2 _uns _awtdiff %if %lowcase(&dsetname.)=adis %then %do; AVAL %end; descending &seq.; run; data anl01fl; set anl01fl; by usubjid paramcd avisitn descending postfl descending _avaln descending _avaln2 _uns _awtdiff %if %lowcase(&dsetname.)=adis %then %do; AVAL %end; descending &seq.; if first.avisitn and ^missing(avisitn) and postfl='Y' and _avaln2=1 then ANL01FL = 'Y'; if ABLFL='Y' then ANL01FL='Y'; run; %mend ablfl; * Derive xxDOSERF, xxRDDY; %put ; %macro xxdoserf(xx=,adt=,adtm=,rddy=,tim=,andwhe=); /* tim=YES for ADAE */ *Most Recent Dose Reference; _rddy="&rddy."; length out_&xx.DOSERF $25; out_&xx.DOSERF = ''; if ^missing(tr01sdt) then do; if (.0 and .<&adt.0) or (((.0 and DOSE2DT=.) or (.0 and .<&adt.0 and .<&adt.. and tr01sdtm>. then &xx.&rddy. = int((&adtm. - tr01sdtm)/(24*60*60) + 1); else &xx.&rddy. = &adt. - tr01sdt + 1; %end; %else %do; &xx.&rddy. = &adt. - tr01sdt + 1; %end; end; else if (.0) or (.0 and TR02SDT=.) or (.0 and TR02SDTM=. and .<&adt.. and dos2dtm>. then &xx.&rddy. = int((&adtm. - dos2dtm)/(24*60*60) + 1); else &xx.&rddy. = &adt. - dose2dt + 1; %end; %else %do; &xx.&rddy. = &adt. - dose2dt + 1; %end; end; else if (.0) or (.0 and .<&adtm.0 and OLDOS2DT=.) %if &andwhe.^= %then %do; or (index(upcase(_rddy),'EN') and &andwhe.='OL Vaccination 1') %end; then do; out_&xx.DOSERF = 'OL Vaccination 1'; %if &tim=YES %then %do; if &adtm.>. and tr02sdtm>. then &xx.&rddy. = int((&adtm. - tr02sdtm)/(24*60*60) + 1); else &xx.&rddy. = &adt. - tr02sdt + 1; %end; %else %do; &xx.&rddy. = &adt. - tr02sdt + 1; %end; end; else if .0) %if &andwhe.^= %then %do; or (index(upcase(_rddy),'EN') and &andwhe.='OL Vaccination 2') %end; then do; out_&xx.DOSERF = 'OL Vaccination 2'; %if &tim=YES %then %do; if &adtm.>. and oldo2dtm>. then &xx.&rddy. = int((&adtm. - oldo2dtm)/(24*60*60) + 1); else &xx.&rddy. = &adt. - oldos2dt + 1; %end; %else %do; &xx.&rddy. = &adt. - oldos2dt + 1; %end; end; end; %mend xxdoserf; * Derive ASTDT, AENDT; %put ; %macro imp_atdt(sten=,vardtc=,trtsdtc=,dendtc=,oriendtc=); imp_&vardtc.=&vardtc.; ori_&trtsdtc.=&trtsdtc.; ori_&dendtc.=&dendtc.; &trtsdtc.=scan(ori_&trtsdtc.,1,'T'); &dendtc.=scan(ori_&dendtc.,1,'T'); length _war $2000; if index(&vardtc.,'--') and index(&vardtc.,'-----')=0 then do; _war='Put Aler'||'t_P: subject='||strip(USUBJID)||', issues to impute ASTDT/AENDT.'|| "&trtsdtc.="||strip(&trtsdtc.)||", &dendtc.="||strip(&dendtc.)||'.'; put _war &vardtc.=; end; if 0=:&trtsdtc. and (lengthn(&oriendtc.)<10 or index(&oriendtc.,'--'))) or (substr(&oriendtc.,1,10)>substr(&trtsdtc.,1,10) and lengthn(&oriendtc.)>=10 and index(&oriendtc.,'--')=0) or missing(&oriendtc.)) then do; imp_&vardtc.=ori_&trtsdtc.; imp_ori_&sten._&trtsdtc. = 'Yes'; end; else imp_&vardtc.=strip(&vardtc.)||'-01-01'; end; else if lengthn(&vardtc.)=7 then do; if scan(&vardtc.,1,'-')=scan(&trtsdtc.,1,'-') and scan(&vardtc.,2,'-')=scan(&trtsdtc.,2,'-') and ((&dendtc.>=:&trtsdtc. and (lengthn(&oriendtc.)<10 or index(&oriendtc.,'--'))) or (substr(&oriendtc.,1,10)>substr(&trtsdtc.,1,10) and lengthn(&oriendtc.)>=10 and index(&oriendtc.,'--')=0) or missing(&oriendtc.)) then do; imp_&vardtc.=ori_&trtsdtc.; imp_ori_&sten._&trtsdtc. = 'Yes'; end; else imp_&vardtc.=strip(&vardtc.)||'-01'; end; %end; *** End Date; %if %lowcase(&sten.)=en %then %do; if lengthn(&vardtc.)=4 then imp_&vardtc.=strip(&vardtc.)||'-12-31'; else if lengthn(&vardtc)=7 then imp_&vardtc.=put(intnx('month',input(compress(&vardtc.||'-15'),yymmdd10.),0,'e'),yymmdd10.); %end; if input(imp_&vardtc.,yymmdd10.)>input(&dendtc.,yymmdd10.) and ^missing(&dendtc.) then do; _war='Put Aler'||'t_C: subject='||strip(USUBJID)||", imp_&vardtc. ("|| strip(imp_&vardtc.)||") > &dendtc. ("||strip(&dendtc.)||').'; put _war; imp_&vardtc.=&dendtc.; end; if lengthn(&vardtc.)=4 then imp_a&sten.dtf='M'; else if lengthn(&vardtc.)=7 and scan(&vardtc.,2,'-')=scan(imp_&vardtc.,2,'-') then imp_a&sten.dtf='D'; else if lengthn(&vardtc.)=7 then imp_a&sten.dtf='M'; a&sten.dtf=imp_a&sten.dtf; end; %mend imp_atdt; **Create Day variable; %put ; %macro caldy(stdt=,endt=,outdy=,stdtm=,endtm=); %if &stdtm.= %then %do; if ^missing(&stdt.) and ^missing(&endt.) then do; if &stdt.>=&endt. then &outdy. = &stdt. - &endt. + 1; else &outdy. = &stdt. - &endt.; end; %end; %else %do; if &stdtm.>=&endtm.>. then &outdy. = int((&stdtm. - &endtm.)/(24*60*60) + 1); else if .<&stdtm.<&endtm. then &outdy. = int((&stdtm. - &endtm.)/(24*60*60)); else if &stdt.>=&endt.>. then &outdy. = &stdt. - &endt. + 1; else if .<&stdt.<&endt. then &outdy. = &stdt. - &endt.; %end; %mend;