<?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: Matching in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Matching/m-p/57240#M12333</link>
    <description>Can you show us a couple of simple data sets that illustrate the problem and the hoped for result?  It might help us understand what you are trying to achieve.</description>
    <pubDate>Wed, 27 Apr 2011 05:39:42 GMT</pubDate>
    <dc:creator>ArtC</dc:creator>
    <dc:date>2011-04-27T05:39:42Z</dc:date>
    <item>
      <title>Matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching/m-p/57239#M12332</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am carrying out a case - controls study. I would like to match 1 control for each case, and the matching is on a continuous variable (age) which is supposed to be +/- 1 year. I would like to have the control to be used only once, rather than being selected more than once for different cases.&lt;BR /&gt;
&lt;BR /&gt;
I would appreciate any help on this.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Hani</description>
      <pubDate>Tue, 26 Apr 2011 22:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching/m-p/57239#M12332</guid>
      <dc:creator>Hani</dc:creator>
      <dc:date>2011-04-26T22:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching/m-p/57240#M12333</link>
      <description>Can you show us a couple of simple data sets that illustrate the problem and the hoped for result?  It might help us understand what you are trying to achieve.</description>
      <pubDate>Wed, 27 Apr 2011 05:39:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching/m-p/57240#M12333</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-04-27T05:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching/m-p/57241#M12334</link>
      <description>Check out&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi29/173-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/173-29.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
I searched support.sas.com for&lt;BR /&gt;
case control matching&lt;BR /&gt;
This is a common problem, so there is no need to reinvent the wheel.&lt;BR /&gt;
&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke</description>
      <pubDate>Wed, 27 Apr 2011 13:34:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching/m-p/57241#M12334</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2011-04-27T13:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching/m-p/57242#M12335</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the replies.&lt;BR /&gt;
&lt;BR /&gt;
Basically, I have a group of cases, and another group of controls.&lt;BR /&gt;
I need to match 1 control for each case on 1 continuous variables (LOS), where the matching criteria is +/- 1.&lt;BR /&gt;
&lt;BR /&gt;
For instance:&lt;BR /&gt;
&lt;BR /&gt;
case subject A, LOS=1.5,&lt;BR /&gt;
case subject B, LOS=2.0,&lt;BR /&gt;
&lt;BR /&gt;
control subject a, LOS=1.7,&lt;BR /&gt;
control subject b, LOS=1.9,&lt;BR /&gt;
&lt;BR /&gt;
In this case, control subject a is a potential controls for both cases A and B, since the LOS is within the 1 year of the case. Similarly, control subject b is a potential controls for both case subjects A and B..  So, what I need is to select a random control for case subject A, and this control should not be replaced in the pool, and thus not to be considered again for case subject B.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Based on the recommended paper published by Hugh Kawabata, I have already used this paper, and following is the program I usedfrom this paper. &lt;BR /&gt;
&lt;BR /&gt;
I know there is something wrong in the coding since very few controls are being selected for all of the cases.&lt;BR /&gt;
&lt;BR /&gt;
Finally, I would appreciate your help in identifying the problem I have&lt;BR /&gt;
&lt;BR /&gt;
Thanks you very much&lt;BR /&gt;
&lt;BR /&gt;
Hani&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data study control;&lt;BR /&gt;
 set matching;&lt;BR /&gt;
 rand_num=uniform(0);&lt;BR /&gt;
if case=1 then output study;&lt;BR /&gt;
else output control;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data control2;&lt;BR /&gt;
	set control;&lt;BR /&gt;
	LOS_low=LOS-1;&lt;BR /&gt;
	LOS_high=LOS+1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table controls_id as&lt;BR /&gt;
select&lt;BR /&gt;
	one.studyid as study_id,&lt;BR /&gt;
	two.studyid as control_id,&lt;BR /&gt;
	one.LOS as study_LOS,&lt;BR /&gt;
	two.LOS as control_LOS,&lt;BR /&gt;
	one.rand_num as rand_num&lt;BR /&gt;
	from study one, control2 two&lt;BR /&gt;
	where (one.LOS between two.LOS_low and two.LOS_high);&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
* count the number of control subjects for each case subject;&lt;BR /&gt;
proc sort data=controls_id ;&lt;BR /&gt;
by study_id ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data controls_id2(keep=study_id num_controls);&lt;BR /&gt;
set controls_id;&lt;BR /&gt;
by study_id;&lt;BR /&gt;
retain num_controls;&lt;BR /&gt;
if first.study_id then num_controls=1;&lt;BR /&gt;
else num_controls=num_controls+1;&lt;BR /&gt;
if last.study_id then output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
* now merge the counts back into the dataset;&lt;BR /&gt;
data controls_id3;&lt;BR /&gt;
merge controls_id&lt;BR /&gt;
      controls_id2;&lt;BR /&gt;
by study_id;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
* now order the rows to select the first matching control;&lt;BR /&gt;
proc sort data=controls_id3;&lt;BR /&gt;
by control_id num_controls rand_num;&lt;BR /&gt;
run;&lt;BR /&gt;
data controls_id4;&lt;BR /&gt;
set controls_id3;&lt;BR /&gt;
by control_id;&lt;BR /&gt;
if first.control_id;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
*Now, as before, randomly select the fixed number (in our example, two) of control subjects for each case.;&lt;BR /&gt;
proc sort data=controls_id ;&lt;BR /&gt;
by study_id rand_num;&lt;BR /&gt;
run;&lt;BR /&gt;
data controls_id2 not_enough;&lt;BR /&gt;
set controls_id;&lt;BR /&gt;
by study_id ;&lt;BR /&gt;
retain num;&lt;BR /&gt;
if first.study_id then num=1;&lt;BR /&gt;
if num le 2 then do;&lt;BR /&gt;
output controls_id2;&lt;BR /&gt;
num=num+1;&lt;BR /&gt;
end;&lt;BR /&gt;
if last.study_id then do;&lt;BR /&gt;
if num le 2 then output not_enough;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print data=controls_id2(obs=40);&lt;BR /&gt;
title2 'matched patients';&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 28 Apr 2011 00:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching/m-p/57242#M12335</guid>
      <dc:creator>Hani</dc:creator>
      <dc:date>2011-04-28T00:11:13Z</dc:date>
    </item>
  </channel>
</rss>

