<?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 How to ensure no statistical differences between groups in covariates when simulating data? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-ensure-no-statistical-differences-between-groups-in/m-p/967761#M376436</link>
    <description>&lt;P&gt;I am simulating data for a 2-groups trial with 100 subjects in each group. There are four variables: GROUP, SUBJNO, SEX, AGE. SEX and AGE are covariates for following model.&lt;/P&gt;
&lt;P&gt;Here is my code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let seed=12345;

data tab1;
  call streaminit(&amp;amp;seed.);
  length subjno $4 sex $1;
  do _n_=1 to 100;
    group=1;
    subjno='1'||put(_n_,z3.);
    sex=choosec(rand('table',0.5,0.5),'M','F');
    age=rand('integer',18,70);
    output;
  end;

  do _n_=1 to 100;
    group=2;
    subjno='2'||put(_n_,z3.);
    sex=choosec(rand('table',0.5,0.5),'M','F');
    age=rand('integer',18,70);
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, The initial random seed, 12345, causes SEX statistical difference on different group, the p value of Chisq is 0.0477.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried new seed value like 123, 1234, 123456, 1234567 and they will not cause&amp;nbsp;SEX statistical difference on different group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know there is a possibility that statistical difference of covariates happens. Is there a way to ensure no statistical differences between groups in covariates when simulating data?&lt;/P&gt;
&lt;P&gt;Maybe&amp;nbsp;&lt;SPAN&gt;block randomization with&amp;nbsp;covariates as block factor? What about continous&amp;nbsp;covariate variable like AGE?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 30 May 2025 08:10:48 GMT</pubDate>
    <dc:creator>whymath</dc:creator>
    <dc:date>2025-05-30T08:10:48Z</dc:date>
    <item>
      <title>How to ensure no statistical differences between groups in covariates when simulating data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-ensure-no-statistical-differences-between-groups-in/m-p/967761#M376436</link>
      <description>&lt;P&gt;I am simulating data for a 2-groups trial with 100 subjects in each group. There are four variables: GROUP, SUBJNO, SEX, AGE. SEX and AGE are covariates for following model.&lt;/P&gt;
&lt;P&gt;Here is my code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let seed=12345;

data tab1;
  call streaminit(&amp;amp;seed.);
  length subjno $4 sex $1;
  do _n_=1 to 100;
    group=1;
    subjno='1'||put(_n_,z3.);
    sex=choosec(rand('table',0.5,0.5),'M','F');
    age=rand('integer',18,70);
    output;
  end;

  do _n_=1 to 100;
    group=2;
    subjno='2'||put(_n_,z3.);
    sex=choosec(rand('table',0.5,0.5),'M','F');
    age=rand('integer',18,70);
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, The initial random seed, 12345, causes SEX statistical difference on different group, the p value of Chisq is 0.0477.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried new seed value like 123, 1234, 123456, 1234567 and they will not cause&amp;nbsp;SEX statistical difference on different group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know there is a possibility that statistical difference of covariates happens. Is there a way to ensure no statistical differences between groups in covariates when simulating data?&lt;/P&gt;
&lt;P&gt;Maybe&amp;nbsp;&lt;SPAN&gt;block randomization with&amp;nbsp;covariates as block factor? What about continous&amp;nbsp;covariate variable like AGE?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 May 2025 08:10:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-ensure-no-statistical-differences-between-groups-in/m-p/967761#M376436</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2025-05-30T08:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to ensure no statistical differences between groups in covariates when simulating data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-ensure-no-statistical-differences-between-groups-in/m-p/967764#M376437</link>
      <description>&lt;P&gt;You want this ?&lt;/P&gt;
&lt;PRE&gt;proc plan seed=123;
factors group=2 ordered subj=100 /noprint;
output out=tab1;
quit;
data tab2;
set tab1;
if subj in (1:50) then sex='F';
 else sex='M';
run;
proc freq data=tab2;
table group*sex/ chisq;
run;
&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1748597192795.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107442i7F3BA08E83B5B212/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1748597192795.png" alt="Ksharp_0-1748597192795.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 May 2025 09:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-ensure-no-statistical-differences-between-groups-in/m-p/967764#M376437</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-05-30T09:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to ensure no statistical differences between groups in covariates when simulating data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-ensure-no-statistical-differences-between-groups-in/m-p/967765#M376438</link>
      <description>Thank you for your reply, would 50:50 be  kind of sedulously? And what about continous covariate variable like AGE?</description>
      <pubDate>Fri, 30 May 2025 09:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-ensure-no-statistical-differences-between-groups-in/m-p/967765#M376438</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2025-05-30T09:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to ensure no statistical differences between groups in covariates when simulating data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-ensure-no-statistical-differences-between-groups-in/m-p/967766#M376439</link>
      <description>Not really,you could use 49:  51 or 48:52 .&lt;BR /&gt;About AGE you could try NORMAL distribution other than uniform distribution.</description>
      <pubDate>Fri, 30 May 2025 09:52:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-ensure-no-statistical-differences-between-groups-in/m-p/967766#M376439</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-05-30T09:52:25Z</dc:date>
    </item>
  </channel>
</rss>

