<?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: Case-control Matching with Multiple data sets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/543257#M150164</link>
    <description>It works in either a data statement or proc sql.</description>
    <pubDate>Thu, 14 Mar 2019 17:23:11 GMT</pubDate>
    <dc:creator>tomrvincent</dc:creator>
    <dc:date>2019-03-14T17:23:11Z</dc:date>
    <item>
      <title>Case-control Matching with Multiple data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/543192#M150145</link>
      <description>&lt;P&gt;Hi all.&lt;BR /&gt;I posted this question before but apparently it looks more like a case of random case-control sampling.&lt;BR /&gt;&lt;BR /&gt;So my data looks like this(Active companies):&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="active.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27903iECD53991A1161D0A/image-size/large?v=v2&amp;amp;px=999" role="button" title="active.png" alt="active.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and like this (inactive companies):&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Inactive.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27904i3C1914229898337F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Inactive.png" alt="Inactive.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I need SAS to randomly select an ACTIVE(so the COSTAT of the company =0) company from the Active data set and pair it to an Inactive company(COSTAT=1) from my second data set.&lt;BR /&gt;The pairing only has two constraint:&lt;BR /&gt;the active company must be in the same industry as the inactive one (same SIC) and the same Fyear for proper analysis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Afterwards any Inactive company that has no match should deleted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My final set should look somehow like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;DATADATE FYEAR DLRSN CONM DLDTE COSTAT SICH&lt;/P&gt;&lt;P&gt;03/12/1992 1989&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;112&lt;/P&gt;&lt;P&gt;03/12/1993 1989&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02&amp;nbsp; &amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1990&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;112&lt;/P&gt;&lt;P&gt;03/12/1994 1990&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;D&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;333&lt;/P&gt;&lt;P&gt;03/12/1992 1990&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; F&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1992&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;333&lt;/P&gt;&lt;P&gt;03/12/1993 1994&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;J&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 445&lt;/P&gt;&lt;P&gt;03/12/1994 1994&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; L&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1996&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 445&lt;/P&gt;&lt;P&gt;03/12/1998 1998&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 001&lt;/P&gt;&lt;P&gt;03/12/1998 1998&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Z&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 001&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Hope it`s clear and you guys can me help me out.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;*UPDATE*&lt;BR /&gt;I used this code to create a random sample data set for the active companies and then merge it with the inactive one. Their is just no pairing what so ever. I just need ONE active for ONE inactive.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyselect data=AltmanV2.Donnee_Avant_F_Sante
					out=StratifiedSRS
					sampsize=1643
					method=srs
					outall;
		strata COSTAT;
run;

data Strat;
set StratifiedSRS;
if Selected=1 then output;
else delete;
run;

data test;
set Strat AltmanV2.Donnee_Avant_F;
SIC=INT(input(SIC,4.)/100);
run;

proc sort data= test;
by Fyear SIC;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 14:41:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/543192#M150145</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-03-14T14:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Case-control Matching with Multiple data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/543207#M150149</link>
      <description>&lt;P&gt;use this to pick a random integer:&lt;BR /&gt;%macro RandBetween(min, max);&lt;BR /&gt;(&amp;amp;min + floor((1+&amp;amp;max-&amp;amp;min)*rand("uniform")))&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;add a record number (_n_) to your dataset and pick a number (%RandBetween(1, 1643 )).&lt;BR /&gt;&lt;BR /&gt;That should help you get your 1 record.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 15:20:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/543207#M150149</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-03-14T15:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Case-control Matching with Multiple data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/543239#M150156</link>
      <description>&lt;P&gt;Where i am suppose to use it?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 16:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/543239#M150156</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-03-14T16:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Case-control Matching with Multiple data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/543257#M150164</link>
      <description>It works in either a data statement or proc sql.</description>
      <pubDate>Thu, 14 Mar 2019 17:23:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/543257#M150164</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-03-14T17:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Case-control Matching with Multiple data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/543330#M150186</link>
      <description>With 9.4m4 or later the you can use the function rand: z = rand("integer", min, max);</description>
      <pubDate>Thu, 14 Mar 2019 21:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/543330#M150186</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-14T21:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Case-control Matching with Multiple data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/544013#M150408</link>
      <description>&lt;P&gt;I integrated the code to the Active company data set like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Random;
set SicMatch;
%macro RandBetween(min, max);
(&amp;amp;min + floor((1+&amp;amp;max-&amp;amp;min)*rand("uniform")))
%mend;
Choice=%RandBetween(1,3154);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and then merged it with the Inactive dataset by choosing only numbers between 1 and 1647 ( so one per intactive company).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;here is the result&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Almost.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/28016iECB38C38AD18EBFF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Almost.png" alt="Almost.png" /&gt;&lt;/span&gt;&lt;BR /&gt;But it still doesn`t quite give me this format:&lt;/P&gt;&lt;P&gt;DATADATE FYEAR DLRSN CONM DLDTE COSTAT SICH&lt;/P&gt;&lt;P&gt;03/12/1992 1989&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;112&lt;/P&gt;&lt;P&gt;03/12/1993 1989&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02&amp;nbsp; &amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1990&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;112&lt;/P&gt;&lt;P&gt;03/12/1994 1990&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;D&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;333&lt;/P&gt;&lt;P&gt;03/12/1992 1990&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; F&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1992&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;333&lt;/P&gt;&lt;P&gt;03/12/1993 1994&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;J&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 445&lt;/P&gt;&lt;P&gt;03/12/1994 1994&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; L&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1996&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 445&lt;/P&gt;&lt;P&gt;03/12/1998 1998&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 001&lt;/P&gt;&lt;P&gt;03/12/1998 1998&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Z&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any clue on how I can arrange my data to obtain this format?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 15:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-control-Matching-with-Multiple-data-sets/m-p/544013#M150408</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-03-18T15:28:51Z</dc:date>
    </item>
  </channel>
</rss>

