Hi,
I need to randomize 1,000 patients to 5 study conditions. I'd like to block on three factors, and preliminary data indicates that there is a predicted percentage of participants that will fall within each level within each factor:
Factor 1=gender: male (60%; female (40%)
Factor2= SUD: OUD only (32%); OUD+otherSUD(68%)
Factor3: psych_severity yes(21%); no(79%)
Please help thank you so much!
Like this ?
ods select none;
proc plan seed=123456789 ;
factors study=1 _gender=1000 ;
output out=factor1;
run;
factors study=1 _SUD=1000;
output out=factor2;
run;
factors study=1 _psych_severity=1000;
output out=factor3;
run;
quit;
ods select all;
data factor1;
set factor1;
gender=ifc(_gender in (1:600),'Male ' ,'Female');
run;
data factor2;
set factor2;
SUD=ifc(_SUD in (1:320),'OUD only ' ,'OUD+otherSUD');
run;
data factor3;
set factor3;
psych_severity=ifc(_psych_severity in (1:210),'yes ' ,'no ');
run;
data want;
merge factor1-factor3;
drop _:;
run;
proc freq data=want;
table gender SUD psych_severity /missing;
run;
Thank you! How do I then get the output to assign condition 1-5 and a random study ID? Thanks!
Add one more factor in it.
ods select none;
proc plan seed=123456789 ;
factors study=1 _gender=1000 ;
output out=factor1;
run;
factors study=1 _SUD=1000 ;
output out=factor2;
run;
factors study=1 _psych_severity=1000 ;
output out=factor3;
run;
factors study=1 _studyid=1000 ;
output out=factor4;
run;
quit;
ods select all;
data factor1;
set factor1;
gender=ifc(_gender in (1:600),'Male ' ,'Female');
run;
data factor2;
set factor2;
SUD=ifc(_SUD in (1:320),'OUD only ' ,'OUD+otherSUD');
run;
data factor3;
set factor3;
psych_severity=ifc(_psych_severity in (1:210),'yes ' ,'no ');
run;
data factor4;
set factor4;
if _studyid in (1:200) then studyid=1;
if _studyid in (201:400) then studyid=2;
if _studyid in (401:600) then studyid=3;
if _studyid in (601:800) then studyid=4;
if _studyid in (801:1000) then studyid=5;
run;
data want;
merge factor1-factor4;
drop _: study;
run;
proc freq data=want;
table gender SUD psych_severity studyid/missing ;
run;
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.