Hi Everyone, Please help me with the below randomization. 3 types of injections (A, B and C) are randomised to 3 locations in each arm (L1 L2 L3 R1 R2 R3). L and R corresponds to LEFT AND RIGHT arms respectively. For each arm, A has to be given at least once, remaining two locations in each arm can be allocated to either B or C. It can both be B. Also It can both be C or It can be B and C. I use PROC PLAN to generate random numbers and writing it to a SAS dataset. Thanks in advanced. This is what I got to so far. proc plan seed=1832577; factors a=20 b=6; output out = c; run; %macro calc; data dat(keep = SubjectNr Location arm Treatment allocatedarm allocatedarm2 allocatedarm3 allocTr1 allocTr2 allocTr3); length Treatment $8.; length Location $2.; length arm $5; set c; retain ct ctt allocatedarm allocatedarm2 allocatedarm3 allocTr1 allocTr2 allocTr3; if ct = . or ct ne a then do; ct = a; ctt = 0; end; ctt = ctt + 1; if b<= 3 then do; arm='right'; end; else arm='left'; if ctt=1 then do; treatment = 'A'; allocatedarm=arm; allocTr1= treatment; end; if ctt=2 then do; if arm ne allocatedarm then do; treatment = 'A'; end; else do; treatment = 'B or C'; end; allocatedarm2=arm; allocTr2 = treatment; end; if ctt=3 then do; if (allocTr1 eq allocTr2) or (allocatedarm eq allocatedarm2) then treatment = 'B or C'; if (allocatedarm eq allocatedarm2) and (arm ne allocatedarm) then treatment = 'A'; allocatedarm3=arm; allocTr3 = treatment; end; if ctt=4 then do; if (arm ne allocatedarm) and (allocatedarm2 ne allocatedarm) and (allocatedarm3 ne allocatedarm) then treatment = 'A'; end; SubjectNr = a; location = b; run; /* proc sort data = dat out = dat; by SubjectNr; run; */ ods rtf file = " .rtf"; footnote ""; proc print data = dat noobs; var SubjectNr Location Treatment arm allocatedarm allocatedarm2 allocatedarm3 allocTr1 allocTr2 allocTr3; run; ods rtf close; %mend; %calc; quit;
... View more