Construct a design with balanced replication of treatments in blocks. For subjects at several locations, randomly assign treatments to subjects such that the treatments are equally replicated.
In this example, there are four subjects at each location and you want to assign a treatment to each subject so that each treatment is applied to exactly two subjects at every location.
REQUIREMENTS:
Base SAS and SAS/STAT Software is required.
DETAILS:
PROC PLAN is used to output a data set of location and treatment combinations and a data set of randomized subject numbers within each location. Merging these data sets by location effectively randomizes the assignment of subjects to location-treatment combinations.
Change the SEED= value, or remove the SEED= option, to get a different randomization.
LIMITATIONS:
The numbers of subjects at the locations (blocks) must be equal.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
See the Results tab for the results of running the following SAS code.
title;
/* Code your actual site and subject names with values 1,2,3,... in
* variables LOCATION and SUBJECT.
----------------------------------------------------------------------*/
data subjects;
do location=1 to 3;
do subject=1 to 4;
input site $ name $;
output;
end;
end;
datalines;
Boston Anderson
Boston Jones
Boston Peters
Boston White
Raleigh Roberts
Raleigh Smith
Raleigh Bennett
Raleigh Williams
Atlanta Martin
Atlanta Brown
Atlanta Wood
Atlanta Fisher
;
proc plan seed=3984898;
/* First, generate the basic runs and replicates of the design */
factors location=3 ordered treat=2 ordered rep=2 ordered;
output out=runs;
/* Then generate subject IDs, randomized within locations */
factors location=3 ordered subject=4;
output out=ids;
run;
/* Merge the design with the randomized subject IDs
--------------------------------------------------------------------- */
data design;
merge runs ids;
by location;
drop rep;
run;
/* Sort the design and merge it with the data set of actual site and
* subject names. Then print the final design.
----------------------------------------------------------------------*/
proc sort;
by location subject;
run;
data final;
merge design subjects;
by location subject;
drop location subject;
run;
proc print noobs;
by site notsorted;
title "The randomized design";
run;
title;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
The PLAN Procedure
Factor
Select
Levels
Order
location
3
3
Ordered
treat
2
2
Ordered
rep
2
2
Ordered
location
treat
rep
1
1
1
2
2
1
2
2
1
1
2
2
1
2
3
1
1
2
2
1
2
The PLAN Procedure
Factor
Select
Levels
Order
location
3
3
Ordered
subject
4
4
Random
location
subject
1
4
3
2
1
2
2
3
4
1
3
1
4
2
3
The randomized design
site=Boston
treat
name
2
Anderson
2
Jones
1
Peters
1
White
site=Raleigh
treat
name
2
Roberts
1
Smith
1
Bennett
2
Williams
site=Atlanta
treat
name
1
Martin
2
Brown
2
Wood
1
Fisher
Construct a design with balanced replication of treatments in blocks.
For subjects at several locations, randomly assign treatments to
subjects such that the treatments are equally replicated.