<?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: Merge to Exclude Certain Cases in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merge-to-Exclude-Certain-Cases/m-p/98217#M27646</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want&lt;/P&gt;&lt;P&gt;as select * from have t1&lt;/P&gt;&lt;P&gt;where not exists (select * from want where health_card_number=t1.health_card_number and death_indicator=true);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.*&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; have t1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left outer join (select distinct health_card_number from want where death_indicator=true) t2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.health_card_number=t2.health_card_number&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t2.health_card_number is null;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Feb 2013 17:30:55 GMT</pubDate>
    <dc:creator>DBailey</dc:creator>
    <dc:date>2013-02-05T17:30:55Z</dc:date>
    <item>
      <title>Merge to Exclude Certain Cases</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-to-Exclude-Certain-Cases/m-p/98215#M27644</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 am using SAS 9.3.&amp;nbsp; I have a dataset where one record is one hospital visit. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am running the data by health card number (unique) and I want to exclude ALL records per health card number when one of the visits indicates death.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know about using merge and "not in" but that was for a single record; this is excluding any record based on health card number.&amp;nbsp; I imagine I would still create a separate data set of deaths but just not sure how to remove all versus just the record not in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any and all assistance greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Feb 2013 15:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-to-Exclude-Certain-Cases/m-p/98215#M27644</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2013-02-05T15:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merge to Exclude Certain Cases</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-to-Exclude-Certain-Cases/m-p/98216#M27645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It will be helpful to see an example of your dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Feb 2013 16:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-to-Exclude-Certain-Cases/m-p/98216#M27645</guid>
      <dc:creator>VD</dc:creator>
      <dc:date>2013-02-05T16:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Merge to Exclude Certain Cases</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-to-Exclude-Certain-Cases/m-p/98217#M27646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want&lt;/P&gt;&lt;P&gt;as select * from have t1&lt;/P&gt;&lt;P&gt;where not exists (select * from want where health_card_number=t1.health_card_number and death_indicator=true);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.*&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; have t1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left outer join (select distinct health_card_number from want where death_indicator=true) t2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.health_card_number=t2.health_card_number&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t2.health_card_number is null;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Feb 2013 17:30:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-to-Exclude-Certain-Cases/m-p/98217#M27646</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-02-05T17:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: Merge to Exclude Certain Cases</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-to-Exclude-Certain-Cases/m-p/98218#M27647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;shellp55,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBailey's approach should work. Below is the solution I offer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If death_indicator = (0 : lived, 1 : died), then the following approaches should clean your dataset of deceased patients:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data patients;&lt;/P&gt;&lt;P&gt; input card_number visit death_indicator 8.;&lt;/P&gt;&lt;P&gt; datalines;&lt;/P&gt;&lt;P&gt;1 1 0&lt;/P&gt;&lt;P&gt;1 2 0&lt;/P&gt;&lt;P&gt;1 3 0&lt;/P&gt;&lt;P&gt;2 1 0&lt;/P&gt;&lt;P&gt;2 2 1&lt;/P&gt;&lt;P&gt;3 1 0&lt;/P&gt;&lt;P&gt;3 2 0&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;APPROACH ONE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt; create table living_patients as&lt;BR /&gt; select a.* &lt;BR /&gt; from patients as a&lt;BR /&gt; left join (select distinct * from patients where death_indicator = 1) as b&lt;BR /&gt; on a.card_number = b.card_number&lt;BR /&gt; where b.death_indicator ne 1;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;APPROACH TWO&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc sort data=patients;&lt;BR /&gt; by card_number descending death_indicator;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data living_patients;&lt;BR /&gt; set patients;&lt;BR /&gt; by card_number descending death_indicator;&lt;BR /&gt; retain deceased_card_number;&lt;BR /&gt; if first.card_number and death_indicator = 1 then deceased_card_number = card_number;&lt;BR /&gt; if card_number ne deceased_card_number;&lt;BR /&gt; drop deceased_card_number;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Huey&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Feb 2013 19:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-to-Exclude-Certain-Cases/m-p/98218#M27647</guid>
      <dc:creator>hdodson_pacificmetrics_com</dc:creator>
      <dc:date>2013-02-05T19:21:52Z</dc:date>
    </item>
  </channel>
</rss>

