<?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: block randomization in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143418#M38152</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;gotcha. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 03 May 2014 03:44:37 GMT</pubDate>
    <dc:creator>grayab</dc:creator>
    <dc:date>2014-05-03T03:44:37Z</dc:date>
    <item>
      <title>block randomization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143413#M38147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a sample of 60 units that need to be randomized to treatment and control (30 and 30).&amp;nbsp; However, I have several subgroups I want to block on, such that the units within them are randomized within the subgroups. There should be .5 probability of randomization within each block.&amp;nbsp; I would like an outcome roughly like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Group1 (6 units):&amp;nbsp; 3T, 3C&lt;/P&gt;&lt;P&gt;Group2 (10 units): 5T, 5C&lt;/P&gt;&lt;P&gt;Group3 (6 units): 3T, 3C&lt;/P&gt;&lt;P&gt;Group4 (38 units): 19T, 19C&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure how to code for this.&amp;nbsp; I was thinking of something along these lines, but this doesn't seem to be quite right: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SURVEYSELECT DATA=mysample method = sys rate = 0.5 seed = 11235813 out=OUTFILE outall;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STRATA Group1 Group2 Group3 Group4;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Run;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;DATA assignment; SET OUTFILE;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SamplingWeight GT 0 THEN GROUP = 'TREATMENT';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SamplingWeight EQ 0 THEN GROUP = 'CONTROL';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;RUN;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;A second question is how I should set up my data file to facilitate this.&amp;nbsp; I currently have binary indicator variables for each subgroup.&amp;nbsp; How do I write the code to ensure that only the 1s for a given subgroup are randomized within that block?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I realize this is a complex question. I appreciate any suggestions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 May 2014 01:07:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143413#M38147</guid>
      <dc:creator>grayab</dc:creator>
      <dc:date>2014-05-03T01:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: block randomization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143414#M38148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assign a random number R to each unit. Sort your units by Group and R. Take the first 3 units for Group 1 T, the next 3 for Group 1 C, the next 5 for Group 2 T, and so on. The assignment will be perfectly random within each Group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 May 2014 02:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143414#M38148</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-05-03T02:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: block randomization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143415#M38149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One simple way to do this is with dataset interleaving :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Define groups treatments and units, unrandomized */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data units;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;input grp trt $ id $ @@;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 C A 1 C B 1 C C&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 T D 1 T E 1 T F&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2 C G 2 C H 2 C I 2 C J 2 C K&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2 T L 2 T M 2 T N 2 T O 2 T P&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Make sure the order is well defined */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=units; by grp trt; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Assign a random number to every unit */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data randomIds;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;call streamInit(233434);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set units;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ran = rand("UNIFORM");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;keep grp id ran;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Sort random numbers (i.e. randomize units) within every group */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=randomIds; by grp ran; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Interleave units and random assignment */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data assign;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set units;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set randomIds;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop ran;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print data=assign noobs; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 May 2014 03:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143415#M38149</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-05-03T03:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: block randomization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143416#M38150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you.&amp;nbsp; I like this suggestion for its simplicity.&amp;nbsp; One possibly minor issue with it is that (while I did not explain this above) some of groups have odd numbers of units -- a decision will have to be made as to whether the final unit in those groups is assigned to T or C.&amp;nbsp; I feel that this introduces some degree of bias. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wonder if there is a way to use the process you have described above, but to have SAS assign the last unit in the subgroups that have odd numbers of units? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I really appreciate this help.&amp;nbsp; I am a fairly new SAS user and I have not used it for this purpose before. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 May 2014 03:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143416#M38150</guid>
      <dc:creator>grayab</dc:creator>
      <dc:date>2014-05-03T03:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: block randomization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143417#M38151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Remember, YOU define the design in the initial step. So you could have an entry in a group have TRT="D" (instead of "C" or "T") and then drop the unit that ends up randomly assigned to it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 May 2014 03:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143417#M38151</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-05-03T03:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: block randomization</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143418#M38152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;gotcha. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 May 2014 03:44:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/block-randomization/m-p/143418#M38152</guid>
      <dc:creator>grayab</dc:creator>
      <dc:date>2014-05-03T03:44:37Z</dc:date>
    </item>
  </channel>
</rss>

