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
... View more