BookmarkSubscribeRSS Feed
shuang_yoyo
Calcite | Level 5

Hi,

 

I need to calculate a confidence interval for difference betwwen two groups while the successful rate of two groups are both 100%, I used code below:

 

data dummy_in;
    success1 = 'Y'; trtpn = 2; count = 67; output;
    success1 = 'Y'; trtpn = 3; count = 76; output;
    success1 = 'N'; trtpn = 2; count = 0; output;
    success1 = 'N'; trtpn = 3; count = 0; output;
    proc sort; by trtpn success1;
run;

 

proc freq data = dummy_in ;
    tables trtpn*success1/riskdiff(noninf cl=mn(correct=no) method=fm margin=0.1) alpha=.1 exact;
    weight count /zeros;
run;

 

but the outputs shows: Row or column sum zero. No statistics computed for this table.

 

I know that the confidence interval can be computed using Miettinen and Nurminen method using R, but in sas, I cannot avoid the error of 'Row or column sum zero.' so no confidence interval can be outputed.

 

Would anybody can help me with this problem in SAS? Thanks!

 

Regards,

Shuang

 

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hi @shuang_yoyo and welcome to the SAS Support Communities!

 

I think a quick-and-dirty solution would be to replace the zero counts by very small numbers.

 

Example:

 

data dummy_in1;
set dummy_in;
if count=0 then count=1e-9;
run;

ods output PdiffCLs=pdcl;
proc freq data = dummy_in1;
    tables trtpn*success1/riskdiff(noninf cl=mn(correct=no) method=fm margin=0.1) alpha=.1;
    weight count /zeros;
run;

(I omitted the exact option to avoid the warning "Fisher's exact test cannot be computed when there are noninteger frequencies.")

 

 

Part of the output:

 

Confidence Limits for the Proportion (Risk) Difference
            Column 1 (success1 = N)
        Proportion Difference = 0.0000

Type                      90% Confidence Limits

Miettinen-Nurminen-Mee    -0.0344        0.0388

 

 

But let's check if these confidence limits (which are contained in dataset pdcl with greater precision than in the output) are consistent with the formulas given in the documentation, applied to your original dataset including the zero counts (n1 and n2 are the row totals n1. and n2., p1h "p1 hat", p1t "p1 tilde" etc.):

data _null_;
n1=67; n2=76; p1h=0; p2h=0; /* These values could be taken from PROC FREQ output for DUMMY_IN. */
alpha=.1;
set pdcl;
array cl LowerCL UpperCL;
length lhs $12;
do i=1 to 2;
  delta=cl[i];
  dh=p1h-p2h;
  theta=n2/n1;
  d=-p1h*delta*(1+delta);
  c=delta**2+delta*(2*p1h+theta+1)+p1h+theta*p2h;
  b=-(1+theta+p1h+theta*p2h+delta*(theta+2));
  a=1+theta;
  v=b**3/(3*a)**3-b*c/(6*a**2)+d/(2*a);
  u=sign(v)*sqrt(b**2/(3*a)**2-c/(3*a));
  w=(constant('pi')+arcos(v/u**3))/3;
  p1t=2*u*cos(w)-b/(3*a);
  p2t=p1t-delta;
  vdt=p1t*(1-p1t)/n1+p2t*(1-p2t)/n2; /* no factor n/(n-1) because of option "correct=no" */
  t=(dh-delta)/sqrt(vdt);
  lhs=cats('T(', vname(cl[i]), ')=');
  put lhs +(-1) t 11.8;
end;
z=probit(1-alpha/2);
put 'z_alpha/2 =' z 11.8;
run;

Result:

T(LowerCL)= 1.64485357
T(UpperCL)=-1.64485372
z_alpha/2 = 1.64485363

So, both values of the test statistic or rather their absolute values (it seems to me that the abs() is missing in the formula for the acceptance region in the documentation!) are very close to the normal quantile z_alpha/2. This indicates that -0.0344 and 0.0388 are indeed sufficiently precise approximations of the Miettinen-Nurminen-Mee confidence limits.

 

 

 

shuang_yoyo
Calcite | Level 5

Thanks @FreelanceReinhard ! Your answer is really helpful! Regards, Shuang

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2223 views
  • 0 likes
  • 2 in conversation