BookmarkSubscribeRSS Feed
pshaffer122
Calcite | Level 5

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!

 

3 REPLIES 3
Ksharp
Super User

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;
pshaffer122
Calcite | Level 5

Thank you! How do I then get the output to assign condition 1-5 and a random study ID? Thanks!

Ksharp
Super User

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1041 views
  • 0 likes
  • 2 in conversation