<?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 Case-control 1-4 matching by date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Case-control-1-4-matching-by-date/m-p/108689#M22600</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a dataset composed of 1.5 million subjects which are divided into cases and controls. I need SAS coding to create a new dataset composed of all the cases plus four randomly selected controls for each case, matched by date interviewed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is appreciated and I am also available to provide more details if needed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Dec 2012 00:01:30 GMT</pubDate>
    <dc:creator>Walternate</dc:creator>
    <dc:date>2012-12-27T00:01:30Z</dc:date>
    <item>
      <title>Case-control 1-4 matching by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-control-1-4-matching-by-date/m-p/108689#M22600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a dataset composed of 1.5 million subjects which are divided into cases and controls. I need SAS coding to create a new dataset composed of all the cases plus four randomly selected controls for each case, matched by date interviewed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is appreciated and I am also available to provide more details if needed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 00:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-control-1-4-matching-by-date/m-p/108689#M22600</guid>
      <dc:creator>Walternate</dc:creator>
      <dc:date>2012-12-27T00:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Case-control 1-4 matching by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-control-1-4-matching-by-date/m-p/108690#M22601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can match cases and 4 controls that were interviewed on the same day (dateInt) randomly this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;data have;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;input id case DateInt :yymmdd. @@;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;format dateInt date11.;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;datalines;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;1&amp;nbsp; 0 20120101&amp;nbsp; 2 0 20120103&amp;nbsp; 3 1 20120101&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;4&amp;nbsp; 0 20120103&amp;nbsp; 5 0 20120101&amp;nbsp; 6 1 20120103&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;7&amp;nbsp; 0 20120101&amp;nbsp; 8 0 20120102&amp;nbsp; 9 0 20120103&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;10 1 20120103 11 0 20120103 12 0 20120103&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;13 0 20120103 14 0 20120103 15 0 20120103&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;/* Assign a random order to all cases and controls */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;data tmp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;call streaminit(98768976);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;set have;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;rnd = rand("UNIFORM");&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;proc sort data=tmp; by dateInt case rnd; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;proc rank data=tmp out=tmpR;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;by dateInt case;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;var rnd;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;/* Match the first case with the first 4 controls, the second case with controls &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5 to 8 and so on, within each date. */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;proc sql;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;create table want as&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;select ca.dateInt, ca.id as caseId, co.id as controlId&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;from tmpR as ca inner join tmpR as co&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on ca.dateInt=co.dateInt and ca.rnd=ceil(co.rnd/4)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;where ca.case and not co.case;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;drop table tmp, tmpR;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;select * from want;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 03:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-control-1-4-matching-by-date/m-p/108690#M22601</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-12-27T03:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Case-control 1-4 matching by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-control-1-4-matching-by-date/m-p/108691#M22602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PG's approach works for exact date matches.&amp;nbsp; If you want to look for dates 'near' the case-date, do a google search on&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;nearest neighbor match site:sas.com&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for a bunch of related results.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jan 2013 21:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-control-1-4-matching-by-date/m-p/108691#M22602</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2013-01-01T21:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Case-control 1-4 matching by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-control-1-4-matching-by-date/m-p/108692#M22603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the reply. Upon entering the code, I received the following error message: "Column case could not be found in the table/view identified with the correlation name CA" (and another one for the correlation name CO). As I am not conversant in proc sql I am unable to troubleshoot myself and any assistance would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2013 13:57:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-control-1-4-matching-by-date/m-p/108692#M22603</guid>
      <dc:creator>Walternate</dc:creator>
      <dc:date>2013-01-02T13:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Case-control 1-4 matching by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-control-1-4-matching-by-date/m-p/108693#M22604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The message means that dataset tmpR doesn't include a variable named case. It should be there if the previous step (proc rank) ran without error. - PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2013 15:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-control-1-4-matching-by-date/m-p/108693#M22604</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-01-02T15:05:48Z</dc:date>
    </item>
  </channel>
</rss>

