<?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: Create Specific Sized Groups Using RAND(&amp;quot;Table&amp;quot;)? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-Specific-Sized-Groups-Using-RAND-quot-Table-quot/m-p/795174#M255026</link>
    <description>&lt;P&gt;Keep track of the declining number of needed cases (N1, N2, N3) in each TREAT level, and the declining number of total available subjects:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=treat);&lt;BR /&gt;  call streaminit(2822);*Set seed;
  array n {3} (200,200,100);
  do available=sum(of n{*}) to 1 by -1;
    treat=rand("Table",n1/available,n2/available,n3/available);
    output;
    n{treat}=n{treat}-1;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: It can be shown that even though probabilities change over the course of the assignment process, every observation has an equal probability of being assigned to a given group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Editted note: initially forgot to put in the streaminit.&amp;nbsp; It's there now.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Feb 2022 14:20:06 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-02-09T14:20:06Z</dc:date>
    <item>
      <title>Create Specific Sized Groups Using RAND("Table")?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Specific-Sized-Groups-Using-RAND-quot-Table-quot/m-p/795108#M255002</link>
      <description>&lt;P&gt;Hello! I am trying to assign participants to 3 groups using a discrete uniform "table" distribution. I am wondering if there is a way to add to this code to that I get exactly 200, 200, and 100 participants in each group:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data bios675.uniform (keep=treat);&lt;BR /&gt;call streaminit(2822);*Set seed;&lt;BR /&gt;p1=200/500; p2=200/500; p3=100/500;*Set probabilities of three treatment groups;&lt;BR /&gt;do i=1 to 500; *500 participants;&lt;BR /&gt;treat=rand("Table", p1, p2, p3);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm wondering if there is somethign I can do like if a group reaches this number, than stop? Or something like that... Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 05:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Specific-Sized-Groups-Using-RAND-quot-Table-quot/m-p/795108#M255002</guid>
      <dc:creator>keherder</dc:creator>
      <dc:date>2022-02-09T05:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create Specific Sized Groups Using RAND("Table")?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Specific-Sized-Groups-Using-RAND-quot-Table-quot/m-p/795110#M255004</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc plan seed=17431;
factors group=10 subjid=500 / noprint;
output out=temp;
run;
data want;
 set temp;
 if subjid in (1:100) then treat=1;
 if subjid in (101:300) then treat=2;
 if subjid in (301:500) then treat=3;
run;

proc freq data=want;
table group*treat/list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Feb 2022 07:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Specific-Sized-Groups-Using-RAND-quot-Table-quot/m-p/795110#M255004</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-02-09T07:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create Specific Sized Groups Using RAND("Table")?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Specific-Sized-Groups-Using-RAND-quot-Table-quot/m-p/795174#M255026</link>
      <description>&lt;P&gt;Keep track of the declining number of needed cases (N1, N2, N3) in each TREAT level, and the declining number of total available subjects:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=treat);&lt;BR /&gt;  call streaminit(2822);*Set seed;
  array n {3} (200,200,100);
  do available=sum(of n{*}) to 1 by -1;
    treat=rand("Table",n1/available,n2/available,n3/available);
    output;
    n{treat}=n{treat}-1;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: It can be shown that even though probabilities change over the course of the assignment process, every observation has an equal probability of being assigned to a given group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Editted note: initially forgot to put in the streaminit.&amp;nbsp; It's there now.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 14:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Specific-Sized-Groups-Using-RAND-quot-Table-quot/m-p/795174#M255026</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-02-09T14:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create Specific Sized Groups Using RAND("Table")?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Specific-Sized-Groups-Using-RAND-quot-Table-quot/m-p/795178#M255027</link>
      <description>Awesome, this is exactly what I needed, and makes sense! Thank you!</description>
      <pubDate>Wed, 09 Feb 2022 14:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Specific-Sized-Groups-Using-RAND-quot-Table-quot/m-p/795178#M255027</guid>
      <dc:creator>keherder</dc:creator>
      <dc:date>2022-02-09T14:24:43Z</dc:date>
    </item>
  </channel>
</rss>

