<?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 Creating a conditional one to one random control to match a test group in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-a-conditional-one-to-one-random-control-to-match-a-test/m-p/236106#M12496</link>
    <description>&lt;P&gt;I have a client test group&amp;nbsp;that differs based on store location and client spend group ( high, medium low).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a larger group of similar control clients created based on past history. &amp;nbsp;I would like to select a random control client for each test client that shares the same store location and spend level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example of tables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;test: &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 162pt;" border="0" width="216" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 54pt;" span="3" width="72" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD width="72" height="21" style="height: 15.75pt; width: 54pt;"&gt;client id&lt;/TD&gt;
&lt;TD width="72" style="width: 54pt;"&gt;store_number&lt;/TD&gt;
&lt;TD width="72" style="width: 54pt;"&gt;spend_level&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD height="21" align="right" style="height: 15.75pt;"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;30&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD height="21" align="right" style="height: 15.75pt;"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;5&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD height="21" align="right" style="height: 15.75pt;"&gt;3&lt;/TD&gt;
&lt;TD align="right"&gt;10&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD height="21" align="right" style="height: 15.75pt;"&gt;4&lt;/TD&gt;
&lt;TD align="right"&gt;8&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD height="21" align="right" style="height: 15.75pt;"&gt;5&lt;/TD&gt;
&lt;TD align="right"&gt;8&lt;/TD&gt;
&lt;TD align="right"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a potential control group that looks like this but with many more clients, and not weighted the same by store and spend.&lt;/P&gt;
&lt;P&gt;How do I create a control sample that has the same number of clients by store and spend.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if Store 3 has 10 low spend, 20 high spend and 3 medium spend clients, and store 5 has 2 low spend, 1 high spend, and 8 medium spend clients, the control will have the same.&lt;/P&gt;
&lt;P&gt;I'd like this sample to be random within these conditions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you in advance!&lt;/P&gt;
&lt;P&gt;Meredith&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>Mon, 23 Nov 2015 21:47:57 GMT</pubDate>
    <dc:creator>hamhocks</dc:creator>
    <dc:date>2015-11-23T21:47:57Z</dc:date>
    <item>
      <title>Creating a conditional one to one random control to match a test group</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-a-conditional-one-to-one-random-control-to-match-a-test/m-p/236106#M12496</link>
      <description>&lt;P&gt;I have a client test group&amp;nbsp;that differs based on store location and client spend group ( high, medium low).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a larger group of similar control clients created based on past history. &amp;nbsp;I would like to select a random control client for each test client that shares the same store location and spend level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example of tables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;test: &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 162pt;" border="0" width="216" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 54pt;" span="3" width="72" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD width="72" height="21" style="height: 15.75pt; width: 54pt;"&gt;client id&lt;/TD&gt;
&lt;TD width="72" style="width: 54pt;"&gt;store_number&lt;/TD&gt;
&lt;TD width="72" style="width: 54pt;"&gt;spend_level&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD height="21" align="right" style="height: 15.75pt;"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;30&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD height="21" align="right" style="height: 15.75pt;"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;5&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD height="21" align="right" style="height: 15.75pt;"&gt;3&lt;/TD&gt;
&lt;TD align="right"&gt;10&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD height="21" align="right" style="height: 15.75pt;"&gt;4&lt;/TD&gt;
&lt;TD align="right"&gt;8&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.75pt;"&gt;
&lt;TD height="21" align="right" style="height: 15.75pt;"&gt;5&lt;/TD&gt;
&lt;TD align="right"&gt;8&lt;/TD&gt;
&lt;TD align="right"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a potential control group that looks like this but with many more clients, and not weighted the same by store and spend.&lt;/P&gt;
&lt;P&gt;How do I create a control sample that has the same number of clients by store and spend.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if Store 3 has 10 low spend, 20 high spend and 3 medium spend clients, and store 5 has 2 low spend, 1 high spend, and 8 medium spend clients, the control will have the same.&lt;/P&gt;
&lt;P&gt;I'd like this sample to be random within these conditions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you in advance!&lt;/P&gt;
&lt;P&gt;Meredith&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>Mon, 23 Nov 2015 21:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-a-conditional-one-to-one-random-control-to-match-a-test/m-p/236106#M12496</guid>
      <dc:creator>hamhocks</dc:creator>
      <dc:date>2015-11-23T21:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a conditional one to one random control to match a test group</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-a-conditional-one-to-one-random-control-to-match-a-test/m-p/236110#M12497</link>
      <description>&lt;P&gt;You can do that with PROC SURVEYSELECT by specifying a secondary input data set (SAMPSIZE=).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SURVEYSELECT data=input_SAS_dataset_ToSampleFrom /* control clients&amp;nbsp;*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAMPSIZE=Secondary_Input_Data_Set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=SampleSRSwithinStrata&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; method=srs&amp;nbsp;; /* srs = Simple Random Sampling */&lt;/P&gt;
&lt;P&gt;strata store_number spend_level;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can provide stratum sample sizes in the &lt;CODE class="AAvarname"&gt;_NSIZE_&lt;/CODE&gt; (or &lt;CODE class="AAvarname"&gt;SampleSize&lt;/CODE&gt;) variable in the SAMPSIZE= data set.&lt;/P&gt;
&lt;P&gt;The secondary input data set must contain all the STRATA variables, with the same type and length as in the DATA= data set. The STRATA groups should appear in the same order in the secondary data set as in the DATA= data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS/STAT(R) 14.1 User's Guide&lt;BR /&gt;The SURVEYSELECT Procedure&lt;BR /&gt;secondary input data set &lt;BR /&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_surveyselect_details23.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_surveyselect_details23.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get the required stratum sample sizes with a PROC FREQ on your client test group.&lt;/P&gt;
&lt;P&gt;PROC FREQ; tables store_number * spend_level / out=count; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck with this!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2015 23:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-a-conditional-one-to-one-random-control-to-match-a-test/m-p/236110#M12497</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2015-11-23T23:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a conditional one to one random control to match a test group</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-a-conditional-one-to-one-random-control-to-match-a-test/m-p/236123#M12499</link>
      <description>&lt;P&gt;You can also do your own randomisation and gain greater control&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table numbers as
select store_number, spend_level, count(*) as n
from test
group by store_number, spend_level;
quit;

data rndControls;
call streaminit(78576);
set controls;
rnd = rand("UNIFORM");
run;

proc sort data=rndControls; by store_number spend_level rnd; run;

data matchControls;
merge numbers rndControls (in=inControls); by store_number spend_level;
if first.spend_level then count = 0;
if count &amp;lt;= n then do;
    count + inControls;
    if last.spend_level and count &amp;lt; n 
        then missing = n - count;
    output;
    end;
keep store_number spend_level clientId missing;
run;

proc print data=matchControls noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the idea is to put the controls in random order within store_number and spend_level groups and then pick the first control clients that are required to match the test groups.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2015 03:05:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-a-conditional-one-to-one-random-control-to-match-a-test/m-p/236123#M12499</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-11-24T03:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a conditional one to one random control to match a test group</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Creating-a-conditional-one-to-one-random-control-to-match-a-test/m-p/236148#M12501</link>
      <description>&lt;P&gt;I forgot to say that, for the SURVEYSELECT solution, you should put a SEED= value that is a (arbitrary) strictly positive integer (&amp;gt;0). Otherwise your results are not reproducible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the online doc ...&lt;/P&gt;
&lt;P&gt;SEED=number &lt;BR /&gt;specifies the initial seed for random number generation. The SEED= value must be a positive integer. If you do not specify the SEED= option, or if the SEED= value is negative or 0, PROC SURVEYSELECT uses the time of day from the computer’s clock to obtain the initial seed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2015 09:36:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Creating-a-conditional-one-to-one-random-control-to-match-a-test/m-p/236148#M12501</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2015-11-24T09:36:19Z</dc:date>
    </item>
  </channel>
</rss>

