BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
azt5173
Obsidian | Level 7

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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:

https://communities.sas.com/t5/SAS-Data-Mining-and-Machine/Generate-random-order-within-a-set-of-num...

View solution in original post

1 REPLY 1
FreelanceReinh
Jade | Level 19

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:

https://communities.sas.com/t5/SAS-Data-Mining-and-Machine/Generate-random-order-within-a-set-of-num...

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2154 views
  • 3 likes
  • 2 in conversation