Use Clopper-Pearson Method to display CI *;
fu = finv( 1- alpha/2, 2(&nv1.+1), 2N_P);
ucl_pi = (&nv1 +1)fu/(N_P + (&nv1.+1)fu);
fl = finv(1-alpha/2, 2(N_P+1), 2&nv1.);
if &nv1 = 0 then lcl_pi = 0;
else lcl_pi = &nv1./(&nv1. + fl*(N_P+1));
ucl_theta = ucl_pi/(r*(1-ucl_pi));
lcl_theta = lcl_pi/(r*(1-lcl_pi));
qu = 100*(1 - lcl_theta);
ql = 100*(1 - ucl_theta);
if not missing(ql) then lcl = strip(put(ql,8.1));
else lcl = "-(ESC){unicode 221e}";
if not missing(qu) then ucl = strip(put(qu,8.1));
else ucl = 'NE';
vci = "(" || strip(lcl) || ", " || strip(ucl) || ")";
* END *;
text = "First COVID-19 occurrence from 7 days after Dose 2";
/* If probablity is 0 then show <0.0001' and if its 1 then then show >0.9999 **/
if pr_n < 0.0001 then pr = '<0.0001';
else if pr_n 0.9999 then pr = '>0.9999';
/* If VE is missing then show Infinity symbol */
if strip(ve) = '.' then do; ve = "-(ESC){unicode 221e}"; vci = "(NA, NA)"; end;
run;
proc transpose data = pt out = trn prefix = trtn;
var evtn;
id trt01pn;
run;
proc transpose data = pt out = try prefix = trty;
var ptyb;
id trt01pn;
run;
proc sql;
create table final as select a., b., c.*
from trn (drop = name) a,
try (drop = name) b,
tr (drop = name) c;
quit;
* Set up Report *;
ods escapechar="~";
/ ods html file="&outtable."; /
title1 "Vaccine Efficacy (ESC){unicode 2013} First COVID-19 Occurrence From 7 Days After Dose 2";
title2 "(ESC){unicode 2013} Blinded Placebo-Controlled Follow-up Period";
title3 "(ESC){unicode 2013} Subjects Without Evidence of Infection Prior to 7 Days After Dose 2 (ESC){unicode 2013} Evaluable Efficacy (7 Days) Population";
footnote1 "Abbreviations: N-binding = SARS-CoV-2 nucleoprotein(ESC){unicode 2013}binding; NAAT = nucleic acid amplification test; ~nSARS-CoV-2 = severe acute respiratory syndrome coronavirus 2; VE = vaccine efficacy.";
footnote2 "Note: Subjects who had no serological or virological evidence (prior to 7 days after receipt of the last dose) of past SARS-CoV-2 infection (ie, N-binding antibody [serum] negative at Visit 1 and SARS-CoV-2 not detected by NAAT [nasal swab] at Visits 1 and 2), and had negative NAAT (nasal swab) at any unscheduled visit prior to 7 days after Dose 2 were included in the analysis.";
footnote3 "a.(ESC){nbspace 5}N = number of subjects in the specified group. ~nb.(ESC){nbspace 5}n1 = Number of subjects meeting the endpoint definition.";
footnote4 "c.(ESC){nbspace 5}Total surveillance time in 1000 person-years for the given endpoint across all subjects within each group at risk for the endpoint. Time period for COVID-19 case accrual is from 7 days after Dose 2 to the end of the surveillance period.";
footnote5 "d.(ESC){nbspace 5}n2 = Number of subjects at risk for the endpoint.";
footnote6 "e.(ESC){nbspace 5}Confidence interval (CI) for VE is derived based on the Clopper and Pearson method adjusted for surveillance time.";
footnote7 "f.(ESC){nbspace 5}Posterior probability (Pr) was calculated using a beta-binomial model with prior beta (0.700102, 1) adjusted for surveillance time. Refer to the statistical analysis plan, Appendix 2, for more details.";
;
proc report data = final nowd headline headskip split = "*" style(report)=[];
column (text ("Vaccine Group (as Randomized)~{line}" ("BNT162b2 (30 ~{unicode 03BC}g)(N~{super a}=&n1.)" trtn8 trty8) ("Placebo(N~{super a}=&n2.)" trtn9 trty9)) ve vci pr);
define text / "Efficacy Endpoint" flow style(header)=[just=l] style(column)=[cellwidth=3in just=l];
define trtn8 / " n1~{super b}" style(column)=[cellwidth=0.8in just=c];
define trty8 / "Surveillance*Time~{super c} (n2~{super d})" style(column)=[cellwidth=1.5in just=c];
define trtn9 / " n1~{super b}" style(column)=[cellwidth=0.8in just=c];
define trty9 / "Surveillance*Time~{super c} (n2~{super d})" style(column)=[cellwidth=1.5in just=c];
define ve / " VE (%)" style(column)=[cellwidth=0.5in just=c];
define vci / " (95% CI~{super e})" style(column)=[cellwidth=0.5in just=c];
define pr / "Pr (VE >30% | data)~{super f}" style(column)=[cellwidth=0.5in just=c];
run;
ods HTML close;
proc printto;
run;