BookmarkSubscribeRSS Feed
keherder
Obsidian | Level 7

Hello there! I am trying to create a randomziation list with PROC PLAN and I am trying to figure out how to do a random block design (that is, the block size changes randomly). I know how to set a block size, but I would like the block size to change so it is unknown what group the last participant will be placed in (for example, if I know the block size is 4 and my first three participants are places in ABA, I know the 4th will be placed in B. Having random blocks will eliminate this). 

 

Here is example of the code I am trying to manipulate:

 

proc plan seed=12345;

factors blocknum = 10 random treat = 4 random;

output out = list treat nvals=(1 1 0 0) random;

run;

 

What I would like to do is so that 4 changes (aka to 8, 12, etc.) each time where particiapnts will still be allocated to either group at a 1:1 ratio. Thank you for any help I may recieve!

5 REPLIES 5
SteveDenham
Jade | Level 19

Ouch.  My brain is having trouble wrapping around this question.  If you require 1:1 allocation, at least one out of the four will be determined once three in the block are allocated to treatment (note that if the first two units are randomly assigned to treatment A, then both of the last two are determined to be treatment B).  

 

I think you might be able to approach this if you assigned all units randomly without blocking (although the 1:1 requirement still will dictate that at least the last position is predetermined), and then sequentially assign four units at a time to a "block".  Unfortunately, this accomplishes little in the way of assigning treatments in a way that additional variation can be removed as a "nuisance" source.

 

SteveDenham

keherder
Obsidian | Level 7

Hi Steve, 

 

Yes, this is an assignment I'm wokring on and my head hurts too! 

 

But the idea is that with a random block generater, when you are looking at the completed randomization list, you don't know what size any of the blocks are.

 

Yes, if I know the block size is 4, then I will always be able to figure out at least what group every 4th person should be assigned to. But, if the block size is changing (and I don't know how or when), then I won't. So, if for example, I have a group of 40, essentially the code I'm looking for would randomly create blocks of 8, 4, 8, 12, 8 (or another combination) and each block is split 1:1. So when I'm looking at the final list, I really have no idea how the participants were ordered.

SteveDenham
Jade | Level 19

Well, this is probably overly complicated, and you would have to do most, if not all, of it in DATA steps.  Here is my idea:

 

First, assign all subjects to blocks of 4 or whatever size needed to accommodate all treatments exactly once, and call that N.  This would be as simple as using a mod function. 

Second, assign blocks to "super blocks" of some sizes that add to the total, assigning blocks to super blocks based on a uniform random number.

Third, assign subjects to treatment group (or sequence) within super block, based on a second uniform random number.

Fourth, "refill" the subjects to new blocks of size N in such a way that each block of N contains all treatment groups.  This would be the hardest part to code, as you would do something like sequentially go through the super block, selecting subjects to complete a full balanced block of four.

Fifth, assign these new blocks to "final super blocks" of random sizes that are multiples of N.  This partitioning could be done with PROC SURVEYSELECT, or by creating final super blocks based on sampling with replacement possible size values (say N, 2N, 3N) such that you generate a sample of sequences of those 3 numbers.  You would then keep the sequences that summed to the number of available subjects, and select one of those valid sequences using yet another uniform random variable.

 

You might be able to condense all of this into fewer steps. The key is assigning subjects to treatments randomly and then assigning those subjects to slots in the various sized blocks.  You could rearrange within the various sized blocks based on a separate random value. If you work that correctly, I think you might be able drop steps 4 and 5 from the above.

 

SteveDenham

 

 

keherder
Obsidian | Level 7
I will try this, thank you!
Rick_SAS
SAS Super FREQ

Please post the EXACT wording of your assignment. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 1536 views
  • 2 likes
  • 3 in conversation