<?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: How to compare two datasets and exclude IDs that are not included in one of the file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-datasets-and-exclude-IDs-that-are-not/m-p/402577#M278841</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/161016"&gt;@hkim30&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Append your 3 datasets into one. Keep only the last service date per patient.&lt;/P&gt;
&lt;P&gt;Use a SQL inner join to combine your master with the service date DS and with a join condition along the line of below:&lt;/P&gt;
&lt;PRE&gt;master.id=service.id and&amp;nbsp; 0&amp;lt;=intck('month',service.dt_service,master.dt_death)&amp;lt;=12&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Changed pseudo code as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 07:02:48 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2017-10-10T07:02:48Z</dc:date>
    <item>
      <title>How to compare two datasets and exclude IDs that are not included in one of the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-datasets-and-exclude-IDs-that-are-not/m-p/402524#M278840</link>
      <description>&lt;P&gt;Hi. I am working on Medicare Claims data and want to ask a question about how to compare two datasets and exclude IDs that are not included in one of the file. There are some tricky components that I need to take into account, so&amp;nbsp;I am so confused and don't know how to tackle this. Could anyone make any suggestions to approach this task or demonstrate codes to program this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The details for my question are as follow:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have a master file that has a list of my study sample. My sample is a group of patients (var: bene_id)&lt;BR /&gt;who died of cancer in 2013-2014. This dataset has a variable of death date (var: deat_dt).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AND additionally&lt;BR /&gt;&lt;BR /&gt;I have three datasets for each year 2012 (dataset name: Lst_pcs12), 2013 (&lt;SPAN&gt;Lst_pcs13)&lt;/SPAN&gt;, and 2014 (&lt;SPAN&gt;Lst_pcs14)&lt;/SPAN&gt;&amp;nbsp;and each dataset has the list of those who have received at least one primary care service by primary care physicians, along with&lt;BR /&gt;service date (service_dt) for each line of primary care service claim.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;What I have to do is to identify and exclude from my master file anyone who does not have received primary care service by&lt;BR /&gt;PCP. I think I will need to apply a rule that everyone should have at least one primary care service during the last year (12 months)&lt;BR /&gt;prior to death. Could anyone help me out? What should I try?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS 9.3. I sincerely appreciate your help and attention to this inquiry! I am stuck after I created file for a subgroup so I apologize for not being able add my attempted code. Thank you so much!&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, 09 Oct 2017 21:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-datasets-and-exclude-IDs-that-are-not/m-p/402524#M278840</guid>
      <dc:creator>hkim30</dc:creator>
      <dc:date>2017-10-09T21:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two datasets and exclude IDs that are not included in one of the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-datasets-and-exclude-IDs-that-are-not/m-p/402577#M278841</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/161016"&gt;@hkim30&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Append your 3 datasets into one. Keep only the last service date per patient.&lt;/P&gt;
&lt;P&gt;Use a SQL inner join to combine your master with the service date DS and with a join condition along the line of below:&lt;/P&gt;
&lt;PRE&gt;master.id=service.id and&amp;nbsp; 0&amp;lt;=intck('month',service.dt_service,master.dt_death)&amp;lt;=12&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Changed pseudo code as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 07:02:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-datasets-and-exclude-IDs-that-are-not/m-p/402577#M278841</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-10T07:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two datasets and exclude IDs that are not included in one of the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-datasets-and-exclude-IDs-that-are-not/m-p/402593#M278842</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you mean&amp;nbsp;&amp;nbsp; "0&amp;lt;=intck ...",&amp;nbsp;&amp;nbsp; not&amp;nbsp;&amp;nbsp; "0&amp;gt;=intck ...".&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 04:18:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-datasets-and-exclude-IDs-that-are-not/m-p/402593#M278842</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-10T04:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two datasets and exclude IDs that are not included in one of the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-datasets-and-exclude-IDs-that-are-not/m-p/402595#M278843</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;'s suggestion could be implemented as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lst_pcs;
set lst_pcs12 lst_pcs13 lst_pcs14;
run;

proc sql;
create table want as
select 
	a.*,
	b.*
from
	master as a inner join
	(	select * 
		from lst_pcs 
		group by bene_id 
		having service_dt = max(service_dt)) as b 
			on 	a.bene_id = b.bene_id and 
				intck("MONTH", b.service_dt, a.deat_dt) between 0 and 12;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(untested)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 04:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-datasets-and-exclude-IDs-that-are-not/m-p/402595#M278843</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-10-10T04:28:03Z</dc:date>
    </item>
  </channel>
</rss>

