- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have an experiment with 6 conditions and 180 participants. I want to generate numbers to randomly assign participants to one of the conditions. In the end I would like to get the same number of people (30) per condition. Is there a sas function that I can use to randomly generate integers from 1 to 6 to assign to them 180 participants?
Thanks,
Mickie
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can also use proc surveyselect with the groups= option:
%let numUnits = 180; /* number of participants */
%let numTreat = 6; /* number of treatments */
data units;
do Unit = 1 to &numUnits;
output;
end;
run;
proc surveyselect data=units groups=&numTreat seed=86787
out=assignedUnits(rename=groupId=treatment);
run;
proc freq data=assignedUnits ;
tables treatment;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
8 does not evenly divide into 180. You say you want 30 people per condition, but that requires 240 participants.
At any rate, one way to do what you want is to use PROC PLAN in SAS/STAT software. There is a Getting Started example that shows exactly what you ask. Change the macro values in the following code to get random assignment for any number of participants and treatments.
%let numUnits = 180; /* number of participants */
%let numTreat = 8; /* number of treatments */
data Unrandomized;
do Unit=1 to &numUnits;
Treatment = 1 + mod(Unit-1, &numTreat);
output;
end;
run;
/* Randomize the design */
proc plan seed=27371;
factors Unit=&numUnits;
output data=Unrandomized out=Randomized;
run;
proc sort data=Randomized;
by Unit;
run;
proc freq data=Randomized;
tables Treatment;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can also use proc surveyselect with the groups= option:
%let numUnits = 180; /* number of participants */
%let numTreat = 6; /* number of treatments */
data units;
do Unit = 1 to &numUnits;
output;
end;
run;
proc surveyselect data=units groups=&numTreat seed=86787
out=assignedUnits(rename=groupId=treatment);
run;
proc freq data=assignedUnits ;
tables treatment;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
A non-STAT solution:
DATA shuffle ;
SET subjectlist ;
rand_position = RAND('UNIFORM') ;
RUN ;
PROC SORT DATA=shuffle ;
BY rand_position ;
RUN ;
DATA grouped_subjects ;
SET shuffle ;
group_id = CEIL(_N_ / 30) ;
RUN ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here are two distribution you can use.
data _null_;
call streaminit(1234);
do i=1 to 10;
rank=ceil(6*rand('uniform'));
put i=1 rank=;
end;
run;
/*****************/
data _null_;
call streaminit(1234);
do i=1 to 10;
rank=rand('table',1/6,1/6,1/6,1/6,1/6,1/6);
put i=1 rank=;
end;
run;