I have 3 treatments (A,B,C). I need to build a data set with these treatments and allocate the subject according to a 2:1:2 randomization ratio. I have a sample of 2310 so I just divided the treatments as 924 for treatment A(2/5*2310), 462 for treatment B, and 924 treatment C.
Here is what I have so far:
Data treat;
Treatment="A";
Treatment="B";
Treatment="C";
run;
proc surveyselect data=score out=score1
method=SRS
seed=12345678
sampsize=(924 462 924);
strata treatment notsorted;
run;
When I run the code I just get the treatment C for the variable A and B does not show up. Probability of selection is still 0.4 which is not what I want and sample ratio is not really working.
Any help would be greatly appreciated.
Hi @azt5173 and welcome to the SAS Support Communities,
Your dataset TREAT will contain only one observation (Treatment="C") because you forgot to write OUTPUT statements after each of the three assignment statements. This explains why A and B do not occur.
I don't know what your dataset SCORE looks like, but if you want to randomly assign 2310 subjects to three treatment groups, the GROUPS= option of PROC SURVEYSELECT could be helpful:
data subjects;
do subjno=1 to 2310;
output;
end;
run;
proc surveyselect data=subjects groups=(924 462 924)
out=assignment
seed=12345678;
run;
You may want to replace the numeric treatment variable GroupID with values 1, 2, 3 by a character variable TREATMENT with values "A", "B", "C" in dataset ASSIGNMENT afterwards (or just assign a format to map 1 --> "A" etc.).
The above technique as well as an alternative -- PROC PLAN -- were suggested in replies to a similar question in 2016:
Hi @azt5173 and welcome to the SAS Support Communities,
Your dataset TREAT will contain only one observation (Treatment="C") because you forgot to write OUTPUT statements after each of the three assignment statements. This explains why A and B do not occur.
I don't know what your dataset SCORE looks like, but if you want to randomly assign 2310 subjects to three treatment groups, the GROUPS= option of PROC SURVEYSELECT could be helpful:
data subjects;
do subjno=1 to 2310;
output;
end;
run;
proc surveyselect data=subjects groups=(924 462 924)
out=assignment
seed=12345678;
run;
You may want to replace the numeric treatment variable GroupID with values 1, 2, 3 by a character variable TREATMENT with values "A", "B", "C" in dataset ASSIGNMENT afterwards (or just assign a format to map 1 --> "A" etc.).
The above technique as well as an alternative -- PROC PLAN -- were suggested in replies to a similar question in 2016:
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.