<?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 left join in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/left-join/m-p/484438#M287047</link>
    <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to make a dataset which has the following variable :&lt;/P&gt;&lt;P&gt;enrolid, index_date,period_start,period_stop, age,sex,svcdate and code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now one exclusion criteria is that I have to remove patients having serious infection 30 days prior to the index_date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I excluded them, but then i have to calculate incidence rate (IR). To calculate IR i need the variable svcdate but that variable is showing missing when i run this code. I want to know how can i get the svcdates var back by left joining.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*ONLY SERIOUS INFECTIONS*/
proc sql ;	
	create table _02b_allserious as
	select distinct *
	from derived._02b_ser_inf_hosp 
	union
	select distinct *
	from derived._02b_ser_inf_iv 
	union 
	select distinct *
	from derived._02b_ser_inf_any ;
quit ;/*2489*/

/*JOIN WITH COHORT*/
proc sql;
	create table _02b_allserious2 as
	select distinct a.*,b.code,b.svcdate
	from _02b_hiv_tb3 as a 
	inner join _02b_allserious as b 
	on a.enrolid = b.enrolid 
	where (a.index_date-30) le b.svcdate le a.index_date;
quit ;/*2489*/


/*REMOVING PATIENTS WHO HAD A CLAIM BEFORE 30 DAYS FROM OUR COHORT  -STILL WILL HAVE PATIENTS HAVING SERIOUS INFECTIONS AFTER INDEX_DATE */
proc sql ;
	create table derived._02b_allserious3 as
	select distinct a.*
	from _02b_hiv_tb3 as a 
	left join _02b_allserious2 as b 
	on a.enrolid = b.enrolid 
	where b.enrolid is NULL ;
quit ;/*4042*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 06 Aug 2018 16:29:28 GMT</pubDate>
    <dc:creator>manya92</dc:creator>
    <dc:date>2018-08-06T16:29:28Z</dc:date>
    <item>
      <title>left join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/left-join/m-p/484438#M287047</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to make a dataset which has the following variable :&lt;/P&gt;&lt;P&gt;enrolid, index_date,period_start,period_stop, age,sex,svcdate and code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now one exclusion criteria is that I have to remove patients having serious infection 30 days prior to the index_date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I excluded them, but then i have to calculate incidence rate (IR). To calculate IR i need the variable svcdate but that variable is showing missing when i run this code. I want to know how can i get the svcdates var back by left joining.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*ONLY SERIOUS INFECTIONS*/
proc sql ;	
	create table _02b_allserious as
	select distinct *
	from derived._02b_ser_inf_hosp 
	union
	select distinct *
	from derived._02b_ser_inf_iv 
	union 
	select distinct *
	from derived._02b_ser_inf_any ;
quit ;/*2489*/

/*JOIN WITH COHORT*/
proc sql;
	create table _02b_allserious2 as
	select distinct a.*,b.code,b.svcdate
	from _02b_hiv_tb3 as a 
	inner join _02b_allserious as b 
	on a.enrolid = b.enrolid 
	where (a.index_date-30) le b.svcdate le a.index_date;
quit ;/*2489*/


/*REMOVING PATIENTS WHO HAD A CLAIM BEFORE 30 DAYS FROM OUR COHORT  -STILL WILL HAVE PATIENTS HAVING SERIOUS INFECTIONS AFTER INDEX_DATE */
proc sql ;
	create table derived._02b_allserious3 as
	select distinct a.*
	from _02b_hiv_tb3 as a 
	left join _02b_allserious2 as b 
	on a.enrolid = b.enrolid 
	where b.enrolid is NULL ;
quit ;/*4042*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Aug 2018 16:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/left-join/m-p/484438#M287047</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-08-06T16:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: left join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/left-join/m-p/484488#M287048</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/208127"&gt;@manya92&lt;/a&gt;,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Since I can't see the data, it is hard for me to troubleshoot. Is it possible your application of distinct during the join causing it ? Could you kindly remove the distinct during the join operation and try to filter for distinct values in a separate step ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 18:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/left-join/m-p/484488#M287048</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-08-06T18:48:35Z</dc:date>
    </item>
  </channel>
</rss>

