BookmarkSubscribeRSS Feed
vjikong
Calcite | Level 5

Hello, 

I am using SAS v 9.4

I want to generate a randomization scheme for an experimental trial with three treatment groups, ABC, BCD and CDF.  I have a total of 150 subjects for the study and the study is carried out in 5 different study centers. My randomization is in the ratio 2:2:1, ie for every 5 subjects, the allocation scheme is 2 for ABC, 2 for BCD and 1 for CDF. I want to generate the randomization scheme that shows site number, subject number and treatment group.

 

this is my code so far:

 

title "RANDOMIZATION SCHEDULE FOR CLINICAL TRIAL";


Proc format;
value treat 1='ABC'
2='BCD'
3='CDF';
run;
proc plan seed=6457149;
factors block=5 random treat=30
random/noprint;
output out=first
treat nvals=(1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3)
random;
run;
data first(keep=pid block treat);
set first;
pid=put(_n_, z2.);
run;
proc sort; by pid;
run;
proc print noobs uniform split='*';
var pid treat;
label pid="Subject*Number"
treat="Treatment*Group";

 

Thanks

6 REPLIES 6
Jagadishkatam
Amethyst | Level 16

I believe the code seems working fine and giving the expected result. The only update required is for the PID i.e. the format need to be used should be z3.

 

Please let me know if my understanding is incorrect.

 

data first(keep=pid block treat);
set first;
pid=put(_n_, z3.);
run;
Thanks,
Jag
vjikong
Calcite | Level 5
Thanks for the suggestion.
I can, t figure out how to allocate the test individuals to the five different trial centers.
Thank you.
PGStats
Opal | Level 21

You only need to transform any random number into a pid, such as

 

proc plan seed=6457149;
factors block=5 random treat=30
random/noprint;
output out=first
treat nvals=(1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3)
random;
run;

Proc format;
value treat 1='ABC'
2='BCD'
3='CDF';
run;

data second;
call streamInit(88678);
set first;
pid = rand("uniform");
format treat treat.; 
run;

proc rank data=second out=third;
var pid;
run;
PG
data_null__
Jade | Level 19

Seems like this is what you want because for every 5 subjects in a center you want to assign the complete set of treatments in the ratio 2:2:1 at random the other factor don't need to be random.

Centers=5;

Blocks/center=6 of size 5.

Treatment 2:2:1

 

 

 

proc plan seed=6457149;
   factors center=5 ordered block=6 ordered treat=5 random;
   output out=plan treat cvals=('ABC' 'ABC' 'BCD' 'BCD' 'CDF') random;
   run;
   quit;
data plan;
   set plan;
   length usubjid $16;
   subject + 1;
   usubjid = catx('-','XYZ01',vvalue(center),vvalue(subject));
   format subject center z3.;
   run;
proc print;
   run;

Capture.PNG

 

vjikong
Calcite | Level 5

Thank you very much, this was exactly what i needed moreover your code looks very clean. I have been able to tweak your code to my specific need.

Your code even allows me to pull trials names from another data source and randomly allocate them to different treatment centers.

data_null__
Jade | Level 19

This is another somewhat parameterized version. 

 

%let center=5;
%let block=6;
%let ratio = 1 1 2 2 3;
%let treat=%sysfunc(countw(%superq(ratio)));
%let subject=%eval(&center*&block*&treat);
%put _global_;
proc format; value trt 1='Active Low Dose' 2='Active High Dose' 3='Placebo'; quit;

proc plan;
   factors center=&center ordered block=&block ordered treat=&treat random subject=1 of &subject perm / noprint;
   output out=plan treat nvals=(&ratio) random;
   run;
   quit;
data plan;
   retain SYSRANDOM &SYSRANDOM SYSRANEND &SYSRANEND;
   set plan;
   length usubjid $16;
   usubjid = catx('-','XYZ-01',vvalue(center),vvalue(subject));
   format subject center z3.;
   run;
proc print;
   run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 6 replies
  • 3295 views
  • 1 like
  • 4 in conversation