## Example

###
Providing permuted blocks randomization scheme for equal allocation to treatments A and B
Section* *

The RANUNI function in SAS yields random numbers from the Uniform(0,1) distribution (randomly selected a decimal between 0 and 1). These random numbers can be used to generate a randomization scheme. For example, suppose that the probability of assignment to treatments A, B, and C are to be 0.25, 0.25, and 0.5, respectively. Let U denote the random number generated and assign treatment as follows:

- if \(0.00 < U \leq 0.25\)
- if \(0.25 < U \leq 0.50\)
- if \(0.50 < U \leq 1.00\)

This can be adapted for whatever your scheme requires.

Here is a SAS program that provides a permuted blocks randomization scheme for equal allocation to treatments A and B. In the example, the block size is 6 and the total sample size is 48.

```
*******************************************************************************
* This program in SAS provides a permuted blocks randomization scheme for *
* equal allocation of two treatments, denoted as A and B. *
* *
* The user needs to specify values for the desired sample size (sampsize) *
* and the desired block size (blcksize). *
*******************************************************************************;
data values;
samplesize=48;
blocksize=6;
run;
data random;
set values;
nblocks=round(samplesize/blocksize);
na=round(blocksize/2);
nb=blocksize-na;
do block=1 to nblocks by 1;
nna=0;
nnb=0;
do i=1 to blocksize;
subject=i+((block-1)*blocksize);
if nna=na then treatment="B";
if nnb=nb then treatment="A";
else do;
aprob=(na-nna)/(na+nb-nna-nnb);
u=ranuni(0);
if (0<=u<=aprob) then do;
treatment="A";
nna=nna+1;
end;
if (aprob<u<=1) then do;
treatment="B";
nnb=nnb+1;
end;
end;
keep subject treatment;
output;
end;
end;
run;
proc print data=random;
id subject;
var treatment;
title "Randomization Plan for Equal Allocation of Treatments A and B";
run;
```

#### Try It!

Did you get something like this?

Randomization Plan for Equal Allocation of Treatments A and B | |
---|---|

subject |
treatment |

1 |
A |

2 | A |

3 | B |

4 | B |

5 | B |

6 | A |

7 | A |

8 | B |

9 | A |

10 | B |

11 | A |

12 | B |

13 | A |

14 | A |

15 | B |

16 | B |

17 | B |

18 | A |

19 | A |

20 | B |

21 | A |

22 | A |

23 | B |

24 | B |

25 | B |

26 | B |

27 | A |

28 | A |

29 | B |

30 | B |

31 | A |

32 | A |

Remember, your output is not likely to be identical to what we got above, but the number assigned to each treatment should be the same in each group after every set of 4 patients.

Future treatment assignments in a randomization scheme should not be discoverable by the investigator. Otherwise, the minimization of selection bias offered by randomization is lost. The administration of the randomization scheme should not be physically available to the investigator. This usually is not the case in multi-center trials, but the problem usually arises in small single-center trials. Logistical problems can arise in trials with hospitalized patients in which 24-hour access to randomization is necessary. Sometimes, sealed envelopes are used as a means of keeping the randomized treatment assignments confidential until a patient is eligible for entry. However, it is relatively easy for investigators to tamper with the envelope system.

## Example

###
Example randomization plan
Section* *

Many clinical trials rely on pharmacies to package the drugs so that they are masked to investigators and patients. For example, consider a two-armed trial with a target sample size of 96 randomized subjects (48 within each treatment group). The pharmacist constructs 96 drug packets and randomly assigns numeric codes from 01 to 96 which are printed on the drug packet labels. The pharmacist gives the investigator the masked drug packets (with their numeric codes). When a subject is eligible for randomization, the investigator selects the next drug packet (in numeric order). In this way the investigator is kept from knowing which treatment is assigned to which patient.

Here is a SAS program that provides ...

```
*******************************************************************************
* This program in SAS provides a permuted blocks randomization scheme for *
* equal allocation of two treatments, denoted as A and B. *
* *
* The user needs to specify values for the desired sample size (samplesize), *
* the maximum block size (blocksize = a number divisible by 2), and an *
* indicator as to whether the block size is fixed or random (randomblocksize *
* = 0 or 1, respectively). *
*******************************************************************************;
data values;
samplesize=108;
maxblocksize=6;
randomblocksize=1;
run;
data randomization_plan;
set values;
interim_ss+0;
do while(interim_ss<=samplesize);
block+1;
blocksize=maxblocksize;
if randomblocksize=1 then do;
blocksize=ceil(maxblocksize*ranuni(0));
if mod(blocksize,2)=1 then blocksize=blocksize+1;
end;
interim_ss=interim_ss+blocksize;
na=round(blocksize/2);
nb=blocksize-na;
nna=0;
nnb=0;
do i=1 to blocksize by 1;
subject+1;
if nna=na then treatment="B";
if nnb=nb then treatment="A";
else do;
aprob=(na-nna)/(na+nb-nna-nnb);
u=ranuni(0);
if (0<=u<=aprob) then do;
treatment="A";
nna=nna+1;
end;
if (aprob<u<=1) then do;
treatment="B";
nnb=nnb+1;
end;
end;
keep subject treatment block blocksize interim_ss;
output;
end;
end;
run;
proc print data=randomization_plan;
id subject;
var treatment block blocksize;
title "Randomization Plan for Equal Allocation of Treatments A and B";
run;
```