<?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: How to randomize Subjects into 2 groups and balance based on demographics? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846213#M334548</link>
    <description>&lt;P&gt;An example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data heart;
set sashelp.heart;
agegrp = int(AgeAtStart/20);
run;

proc sort data=heart; by Sex agegrp Smoking_Status; run;

proc surveyselect data=heart out=assigned groups=2 seed=96876;
where Smoking_Status is not missing;
strata Sex agegrp Smoking_Status;
run;

proc freq data=assigned;
tables (Sex agegrp Smoking_Status) * GroupID / list nocum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1669317379587.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77680i7D943E125DEDF9AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1669317379587.png" alt="PGStats_0-1669317379587.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Nov 2022 19:16:53 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2022-11-24T19:16:53Z</dc:date>
    <item>
      <title>How to randomize Subjects into 2 groups and balance based on demographics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846077#M334482</link>
      <description>&lt;P&gt;I am working on my doctoral dissertation right now. I have my dataset *wide format, 12,000 subjects) which contains Subject ID, race age and sex for my research study. My goal is to randomize the Subject Ids in my dataset into 2 equal groups (1:1 ratio) and assign each subject to a treatment arm (Group A or Group B) for each subject in my dataset. I would like to have the treatment arm to be closely balanced in&amp;nbsp; race (White, Black, Asian, Other), age (continuous variable) and sex (binary).&amp;nbsp; I assume I need to recode age into age groups of some sort to help with the balance. I have been reading up on randomization methods in SAS and looks like PROC PLAN or PROC SURVEYSELECT is the way to do it. At the moment, I can't figure out the differences between the two approaches, which approach fits would get this task done correctly and how exactly to write my code to create this treatment arm variable. So I was wondering if someone can help me figure out how to do this? I haven't done any type of randomizations before, so I am completely lost here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Screenshot below is my example, I have the dataset, I want to randomize 12,000 subjects into either group A or Group B and have a that as variable treatment arm. When comparing the group A vs group B: t-test (age) or chi-square (Race/sex), p-value are non-significant.&amp;nbsp; The goal is to make the 2 groups as comparable as possible (e.g. Non-Sig). I know it won't be a perfect non-sig P-value, but overall want it as P&amp;gt;0.05.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tpham_0-1669304286813.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77677iA230B32AAA77E92A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tpham_0-1669304286813.png" alt="Tpham_0-1669304286813.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 15:43:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846077#M334482</guid>
      <dc:creator>Tpham</dc:creator>
      <dc:date>2022-11-24T15:43:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to randomize Subjects into 2 groups and balance based on demographics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846086#M334484</link>
      <description>&lt;P&gt;Can you post some sample of your data that represents your actual data and a description of your desired result? Makes it much easier to provide a usable code answer.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 07:32:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846086#M334484</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-24T07:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to randomize Subjects into 2 groups and balance based on demographics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846087#M334485</link>
      <description>&lt;P&gt;“I would like to have the treatment arm to be closely balanced in race (White, Black, Asian, Other), age (continuous variable) and sex (binary). ”&lt;/P&gt;
&lt;P&gt;Can you post an example to explain above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following code could "&lt;SPAN&gt;randomize the Subject Ids in my dataset into 2 equal groups (1:1 ratio)&amp;nbsp;":&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyselect data=sashelp.class out=want group=2 seed=123;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Nov 2022 07:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846087#M334485</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-11-24T07:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to randomize Subjects into 2 groups and balance based on demographics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846093#M334490</link>
      <description>Could detail your requirements regarding the balance with respect to race, age, sex, please? If there is a certain bias in your data (e.g. only male subjects with race "other") it could be difficult to accomplish.</description>
      <pubDate>Thu, 24 Nov 2022 08:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846093#M334490</guid>
      <dc:creator>fja</dc:creator>
      <dc:date>2022-11-24T08:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to randomize Subjects into 2 groups and balance based on demographics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846181#M334530</link>
      <description>&lt;P&gt;Added to my post&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 15:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846181#M334530</guid>
      <dc:creator>Tpham</dc:creator>
      <dc:date>2022-11-24T15:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to randomize Subjects into 2 groups and balance based on demographics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846182#M334531</link>
      <description>&lt;P&gt;Added to my post&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 15:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846182#M334531</guid>
      <dc:creator>Tpham</dc:creator>
      <dc:date>2022-11-24T15:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to randomize Subjects into 2 groups and balance based on demographics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846184#M334533</link>
      <description>&lt;P&gt;thanks, in this case, how do I account for characteristics to ensure the 2 groups are the comparable in terms of their demographics in this randomization code? Overall, after the randomization, I would want to show that randomization work.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 15:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846184#M334533</guid>
      <dc:creator>Tpham</dc:creator>
      <dc:date>2022-11-24T15:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to randomize Subjects into 2 groups and balance based on demographics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846213#M334548</link>
      <description>&lt;P&gt;An example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data heart;
set sashelp.heart;
agegrp = int(AgeAtStart/20);
run;

proc sort data=heart; by Sex agegrp Smoking_Status; run;

proc surveyselect data=heart out=assigned groups=2 seed=96876;
where Smoking_Status is not missing;
strata Sex agegrp Smoking_Status;
run;

proc freq data=assigned;
tables (Sex agegrp Smoking_Status) * GroupID / list nocum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1669317379587.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77680i7D943E125DEDF9AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1669317379587.png" alt="PGStats_0-1669317379587.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 19:16:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846213#M334548</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-11-24T19:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to randomize Subjects into 2 groups and balance based on demographics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846217#M334549</link>
      <description>&lt;P&gt;It's better to add as text not images please.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want it balanced or proportional?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/statcdc/14.2/statug/statug_surveyselect_examples04.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/statcdc/14.2/statug/statug_surveyselect_examples04.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 20:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846217#M334549</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-24T20:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to randomize Subjects into 2 groups and balance based on demographics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846235#M334552</link>
      <description>&lt;P&gt;Calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2022 01:16:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846235#M334552</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-11-25T01:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to randomize Subjects into 2 groups and balance based on demographics?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846239#M334555</link>
      <description>&lt;P&gt;Thanks for your help on this. I've adapted your code and looks like it works!&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2022 02:18:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-randomize-Subjects-into-2-groups-and-balance-based-on/m-p/846239#M334555</guid>
      <dc:creator>Tpham</dc:creator>
      <dc:date>2022-11-25T02:18:51Z</dc:date>
    </item>
  </channel>
</rss>

