<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Generate random order within a set of number. in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285613#M4231</link>
    <description>&lt;P&gt;You can also use proc surveyselect with the groups= option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let numUnits = 180;    /* number of participants */
%let numTreat = 6;      /* number of treatments */

data units;
do Unit = 1 to &amp;amp;numUnits;
	output;
	end;
run;

proc surveyselect data=units groups=&amp;amp;numTreat seed=86787
    out=assignedUnits(rename=groupId=treatment); 
run;

proc freq data=assignedUnits ;
tables treatment;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 19 Jul 2016 19:10:21 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-07-19T19:10:21Z</dc:date>
    <item>
      <title>Generate random order within a set of number.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285601#M4228</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an experiment with&amp;nbsp;6 conditions and 180 participants. I want to generate numbers to&amp;nbsp;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&amp;nbsp;6 to assign to them 180 participants?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mickie&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 18:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285601#M4228</guid>
      <dc:creator>mmjohnson</dc:creator>
      <dc:date>2016-07-19T18:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Generate random order within a set of number.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285604#M4229</link>
      <description>30*8=240 not 180</description>
      <pubDate>Tue, 19 Jul 2016 18:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285604#M4229</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-07-19T18:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Generate random order within a set of number.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285606#M4230</link>
      <description>&lt;P&gt;8 does not evenly divide into 180. &amp;nbsp;You say you want 30 people per condition, but that requires 240 participants. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At any rate, one way to do what you want is to use PROC PLAN in SAS/STAT software. &amp;nbsp;There is a &lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_plan_gettingstarted02.htm" target="_self"&gt;Getting Started example&lt;/A&gt; that shows exactly what you ask. &amp;nbsp;Change the macro values in the following code to get random assignment for any number of participants and treatments. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let numUnits = 180;    /* number of participants */
%let numTreat =   8;    /* number of treatments */

data Unrandomized;
   do Unit=1 to &amp;amp;numUnits;
      Treatment = 1 + mod(Unit-1, &amp;amp;numTreat);
      output;
   end;
run;

/* Randomize the design */
proc plan seed=27371;
   factors Unit=&amp;amp;numUnits;
   output data=Unrandomized out=Randomized;
run;

proc sort data=Randomized;
   by Unit;
run;

proc freq data=Randomized;
tables Treatment;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jul 2016 18:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285606#M4230</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-07-19T18:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Generate random order within a set of number.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285613#M4231</link>
      <description>&lt;P&gt;You can also use proc surveyselect with the groups= option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let numUnits = 180;    /* number of participants */
%let numTreat = 6;      /* number of treatments */

data units;
do Unit = 1 to &amp;amp;numUnits;
	output;
	end;
run;

proc surveyselect data=units groups=&amp;amp;numTreat seed=86787
    out=assignedUnits(rename=groupId=treatment); 
run;

proc freq data=assignedUnits ;
tables treatment;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jul 2016 19:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285613#M4231</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-07-19T19:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Generate random order within a set of number.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285616#M4233</link>
      <description>&lt;P&gt;A non-STAT solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA shuffle ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET subjectlist ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rand_position = RAND('UNIFORM') ;&lt;/P&gt;&lt;P&gt;RUN ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SORT DATA=shuffle ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; BY rand_position ;&lt;/P&gt;&lt;P&gt;RUN ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA grouped_subjects ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET shuffle ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; group_id = CEIL(_N_ / 30) ;&lt;/P&gt;&lt;P&gt;RUN ;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 19:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285616#M4233</guid>
      <dc:creator>Ludwig61</dc:creator>
      <dc:date>2016-07-19T19:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Generate random order within a set of number.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285706#M4234</link>
      <description>&lt;P&gt;Here are two distribution you can use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Jul 2016 01:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Generate-random-order-within-a-set-of-number/m-p/285706#M4234</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-20T01:40:59Z</dc:date>
    </item>
  </channel>
</rss>

