/****************************************************************/ /* S A S Macros */ /* */ /* NAME: mPlan */ /* TITLE: Randomisation Schedule generation */ /* AUTHOR: Jimmy Xiao (jimmy.xiao@ClinStReport.com) */ /* SYSTEM: SAS */ /* DATE: Jul, 2004 */ /* PROCS: Proc Plan */ /* MISC: */ /* */ /****************************************************************/ %Macro mPlan(group=2,Ratio=2:1,block=6,total=144,outset=out,seed=9999); %if %length(%cmpres(&group))=0 %then %let group=2; %if %length(%cmpres(&ratio))=0 %then %let group=2:1; %if %length(%cmpres(&block))=0 %then %let block=6; %if %length(%cmpres(&total))=0 %then %let group=144; %if %length(%cmpres(&OutSet))=0 %then %let OutSet=out; %if %length(%cmpres(&seed))=0 %then %let seed=9999; %let tRatio=0; %do i=1 %to &group; %let Ratio&i=%scan(&Ratio,&i,:); %let tRatio=%eval(&tRatio+&&Ratio&i); %end; %if %sysfunc(mod(&block,&tRatio)) ne 0 %then %do; %put ERROR: Either Parameter BLOCK or RATIO is assigned wrong,macro Stopped!; %goto TheEnd; %end; proc plan seed=&seed ; factors Serial=%eval(&total/&block) ordered block=&block ordered / noprint; treatments treat=█ output out=&outset(drop=block serial) treat cvals=( %do i=1 %to %eval(&block/&tRatio); %do j=1 %to &group; %do k=1 %to &&ratio&j; "%sysfunc(byte(&j+64))" %end ; %end; %end;);; run; data &outset; format patient best.; set &outset; patient=_N_; run; %theEnd:; %mend; /* Sample Usage */ /* To generate 144 randomization codes for 1:1 designed two treatment arms trial */ %mPlan(group=2,Ratio=1:1,block=4,total=144,outset=out1,seed=9999);