Sunday, June 14, 2015

Sample Size and Power Calculation Using SAS Proc Power and twosamplesurvival Statement

For sample size and power calculations, several commercially available software can be used. The commonly used ones are EAST, PASS, and NQuery Advisor. SAS has a procedure (PROC POWER) that can be used for sample size and power calculations for many types of the study designs / study endpoints. One of the statements (twosamplesurvival) in Proc Power is for comparing two survival curves and calculating the sample size/power for time to event variable.

The syntax and descriptions for Twosamplesurvival statement in PROC POWER can be found on SAS website. It can be used to calculate:

  • the total number of events needed (EVENTSTOTAL = .  Option)
  • the total number of subjects needed (NTOTAL = . Option)
  • the number of subjects needed per treatment group (NPERGROUP=. Option)
  • the statistical power (POWER=. Option)

Notice that only one option designated as the result is allowed. If we want to get both the total number of events and the total number of subjects, we would need to run the program two times: one for solving the total number of events and one for solving the total number of subjects.

Here are some of the example applications of using twosamplesurvival statement.


In a SUGI paper "Proc Power in SAS 9.1" by Bauer, Lavery, and Ford, an example was provided to calculate the sample size for log-rank test with 2:1 randomization ratio and with drop out.

The example assumes 30% of placebo patients are sustained responders (exponential hazard =0.3567) compared to 45 or 50% for the treatment group (exp. hazard = 0.5978 or 0.6931). Twice as many patients are on treatment as placebo, and all patients are enrolled at the beginning of the study with a 30% drop-out rate.

Prior to the sample size calculation, the event rates were converted to hazards. Exponential hazard in Placebo group = - ln(1 - event rate) = -ln(1-0.3) = 0.3567.  Similarly, Exponential hazards corresponding to 45% or 50% event rate were 0.5978 and 0.6931.

The dropout rate were also converted to group loss hazards in the same way. Therefore, the 30% dropout rate was corresponding to the group loss hazard of -ln(1-dropout rate)=-ln(1-0.3)=0.3567.

Groupweights statement was used to indicate the 2:1 randomization ratio. 

proc power;
       twosamplesurvival test=logrank
       gexphs= 0.3567 | 0.5978 .6931
       grouplossexphazards=(0.3567 0.3567)
       accrualtime = 1
       followuptime = 1
       groupweights = (1 2)
       power = .


Dr Hudgens from UNC had a nice posting about the power and sample size calculations for log-rank test. He gave an example as following:

Clinical trial to assess new treatment for patients with chronic active hepatitis. Under standard treatment, 41% of patients survive beyond 5 years. Expect new treatment to increase survival beyond 5 years to 60%.

In order to calculate the sample size, we will need to calculate some parameters.
Event rate for standard treatment (Ec) = 1-0.41 = 0.59
Event rate for new treatment (Et) = 1-0.60 = 0.4
Since event rate E = 1 - exp(-t*HAZARD), we have HAZARD = -ln((1-E)/t   
The Hazard for standard treatment is HAZARDc=-ln(1-Ec)/t = -ln(1-0.59)/t = -ln(0.41)/t
The Hazard for new treatment is HAZARDt = -ln(1-Et)/t = -ln(1-0.40)/t = -ln(0.60)/t
The hazard ratio  = HAZARDt/HAZARDc = ln((0.6)/ln(0.41)=0.5729
T=5, the hazard for standard treatment is HAZARDc = -ln(0.41)/5 = 0.178

After these calculation, the following SAS codes can be used to calculate the sample size:

proc power;
    twosamplesurvival test=logrank
    hazardratio = 0.57
    followuptime = 5
    totalTIME = 5
    power = 0.90
    ntotal = . ;

EXAMPLE #3: Sample Size Calculation with piecewise linear survival curve

SAS has a GUI desktop application PSS (the Power and Sample Size Application) that provides easy access to power analysis and sample size determination techniques. Anything implemented in PSS desktop application can also be realized using Proc Power. Here is a link to an example from using PSS desktop application. The calculation can be realized using Proc Power Twosamplesurvival.

Suppose you want to compare survival rates for an existing cancer treatment and a new treatment. You intend to use a log-rank test to compare the overall survival curves for the two treatments. You want to determine a sample size to achieve a power of 0.8 for a two-sided test using a balanced design, with a significance level of 0.05.

The survival curve of patients for the existing treatment is known to be approximately exponential with a median survival time of five years. You think that the proposed treatment will yield a survival curve described by the times and probabilities listed in Table 69.9. Patients are to be accrued uniformly over two years and followed for three years.

Table 69.9 Survival Probabilities for Proposed Treatment

The descriptions for using PSS desktop application for this example can be found on SAS website. The following program will do exactly the same.

proc power;
      twosamplesurvival test=logrank
       curve("Existing Treatment") = 5 : 0.5
      curve("Proposed Treatment") = 1 : 0.95 2 : 0.90 3:0.75  4:0.70 5:0.60
      groupsurvival = "Existing Treatment" | "Proposed Treatment"
      accrualtime = 2
      power = 0.80
      npergroup = . ;

twosamplesurvival statement embedded in PROC SEQDESIGN can be used to estimate the sample size for group sequential design with interim analyses.

In the following SAS program to calculate the sample size, the survival probability at 12 months are for standard and proposed groups are specified and the statement of grouplossexphazards is used to account for the dropout rate.

proc power;
      twosamplesurvival test=logrank
      curve(“Standard”) = 12 : 0.8781
      curve(“Proposed”) = 12 : 0.9012
      groupsurvival = “Standard” | “Proposed”
      accrualtime = 18
      Totaltime = 24
      GROUPLOSSEXPHAZARDS = (0.0012 0.0012)
      power = 0.85
      ntotal = . ;


Mingyuan Shao said...

In your Example #1, the exponential survival hazard is calculated as -ln(1 - event rate). To be more accurate, it would be -ln(1 - event rate)/t. Because t in this example is 1, the formula is simplified to -ln(1 - event rate), but as an online tutorial, it would be better off to have the complete formula. The complete formula is actually already reflected in Example #2. The formula for loss to follow-up, -ln(1-dropout rate), though, is correct, since in this context loss "is ... indicating the expected rate of censoring over time" according to the SAS manual (in other words, there is no need to divide by t).

In your Example #5, follow-up time = 24 - 18 = 6. How come in the curve option the specified time is 12 which is way beyond 6?

Anonymous said...

There is something fishy going on in example #1.
First of all, a sustained responder is a good thing. Therefore, this should not be considered the event. If it were, then the placebo group would be expected to do better... ? Hence, the exponential hazard would be - ln(1 - event rate)/T with T=1 and thus = - ln(0.30).
Furthermore, the groupweights = (1 2) is in the incorrect order, and should be (2 1) based on the other statements in the proc power.