<?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: Proc plan in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-plan/m-p/646055#M22073</link>
    <description>&lt;P&gt;This blog post by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;shows how to use the RandContingency function to control both the row and column sums (the Batch and Group sums in your example):&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2015/10/21/simulate-contingency-tables-fixed-sums-sas.html" target="_self"&gt;Simulate contingency tables with fixed row and column sums in SAS&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 May 2020 22:25:03 GMT</pubDate>
    <dc:creator>Watts</dc:creator>
    <dc:date>2020-05-07T22:25:03Z</dc:date>
    <item>
      <title>Proc plan</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-plan/m-p/645940#M22070</link>
      <description>&lt;P&gt;Using SAS 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running the following code to randomize 273 units into 3 groups with 91 units per groups. However, is it possible to set up the distribution in such a way that every 50 units is evenly distributed among the 3 groups?&amp;nbsp;&lt;/P&gt;&lt;P&gt;meaning the first 50 units would have group 1-17 units, group 2-17 units, group 3-16 units. Thank you for any help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Unrandomized;&lt;BR /&gt;do unit=1 to 273;&lt;BR /&gt;if (unit &amp;lt;= 91) then Group=1;&lt;BR /&gt;else if (91 &amp;lt; unit &amp;lt;= 182) then Group=2;&lt;BR /&gt;else Group=3;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;/* Randomize the design */&lt;BR /&gt;proc plan seed=22042;&lt;BR /&gt;factors unit=273;&lt;BR /&gt;output data=Unrandomized out=Randomized;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=Randomized;&lt;BR /&gt;by unit;&lt;BR /&gt;proc print data=Randomized;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 16:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-plan/m-p/645940#M22070</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-05-07T16:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc plan</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-plan/m-p/646000#M22071</link>
      <description>&lt;P&gt;One way to randomly assign units to groups is the&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_surveyselect_syntax01.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en#statug.surveyselect.selectgroups" target="_self"&gt;GROUPS=&lt;/A&gt;&amp;nbsp;option in PROC SURVEYSELECT.&lt;/P&gt;
&lt;P&gt;For example, this code creates 3 equal (or near-equal) size groups for each batch of 50 observations.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data UnRandomized;
do unit=1 to 273;
   if (unit &amp;lt;= 50) then Batch=1;
   else if (unit &amp;lt;= 100) then Batch=2;
   ....
   output;
end; 
run; 

proc surveyselect data=UnRandomized groups=3 seed=123
   out=randomGroups;
strata Batch;
run;

proc&amp;nbsp;freq&amp;nbsp;data=randomGroups;
tables&amp;nbsp;Batch*groupID;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 18:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-plan/m-p/646000#M22071</guid>
      <dc:creator>Watts</dc:creator>
      <dc:date>2020-05-07T18:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc plan</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-plan/m-p/646022#M22072</link>
      <description>So that worked for my original question, which is why I accepted the solution. However, in using this method the ending total between the groups is not even. Meaning group 1 has 87 and groups 2 and 3 have 93. Is there a way to run this to ensure that each group has 91 in the final summation? So, basically the group with the small number ( ie 16 vs 17 vs 17) needs to rotate between the 3 groups instead of always being group 1. Is this possible? Thank you&lt;BR /&gt;&lt;BR /&gt;data UnRandomized;&lt;BR /&gt;do unit=1 to 273;&lt;BR /&gt;if (unit &amp;lt;= 50) then Batch=1;&lt;BR /&gt;else if (unit &amp;lt;= 100) then Batch=2;&lt;BR /&gt;else if (unit &amp;lt;= 150) then Batch=3;&lt;BR /&gt;else if (unit &amp;lt;= 200) then Batch=4;&lt;BR /&gt;else if (unit &amp;lt;= 250) then Batch=5;&lt;BR /&gt;else if (unit &amp;lt;= 273) then Batch=6;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sort data = UnRandomized;&lt;BR /&gt;by batch;&lt;BR /&gt;run;&lt;BR /&gt;proc surveyselect data=UnRandomized groups=3 seed=22042&lt;BR /&gt;out=randomized;&lt;BR /&gt;strata Batch;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc freq data=randomized;&lt;BR /&gt;tables Batch*groupID;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 07 May 2020 20:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-plan/m-p/646022#M22072</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-05-07T20:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc plan</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-plan/m-p/646055#M22073</link>
      <description>&lt;P&gt;This blog post by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;shows how to use the RandContingency function to control both the row and column sums (the Batch and Group sums in your example):&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2015/10/21/simulate-contingency-tables-fixed-sums-sas.html" target="_self"&gt;Simulate contingency tables with fixed row and column sums in SAS&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 22:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-plan/m-p/646055#M22073</guid>
      <dc:creator>Watts</dc:creator>
      <dc:date>2020-05-07T22:25:03Z</dc:date>
    </item>
  </channel>
</rss>

