<?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: observations discrepency in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486811#M126722</link>
    <description>&lt;P&gt;WHERE filters out the data. If you remove that do you get the records you want?&lt;/P&gt;
&lt;P&gt;Look at the missing records and determine what condition is excluding them....with less than a 100 records you can manually verify it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/208127"&gt;@manya92&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I changed that to a left join but now i have 89 obsv&amp;nbsp;still not 92&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Aug 2018 20:18:52 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-08-14T20:18:52Z</dc:date>
    <item>
      <title>observations discrepency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486800#M126717</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to add a variable called height to my cohort dataset by left joining. I have 92 observations in my cohort so I am expecting the final number to be 92 after the join since I am only left joining (adding variables&amp;nbsp;to the existing&amp;nbsp;conditions). I am including both scenarios&amp;nbsp;where height is missing and not missing. I am only getting 64 observations. I only want to see the most recent record of height 30 days prior to the index date. Attached is my code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know how can I solve this.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;*height most recent height within 30 days prior to the index date;
proc sql ;
	create table _02a_ht as 
	select a.*, b.labcomponent, b.TestResultCleaned,b.TestDate,
	case 
		when (a.index_date-30) le b.TestDate le a.index_date  and b.labcomponent ='Body Height' and b.TestResultCleaned ne .
		then b.TestResultCleaned 
		else .
	end as height	
	from _02a_ecog2 as a
	inner join dfi_panc.vitals as b 
	on a.PatientID=b.PatientID and b.labcomponent ='Body Height'
	order by a.PatientID,b.TestDate;
quit ;/*3463 */

*making sure the testdate is 30 days prior the index date;
data _02a_testdate;	
	set _02a_ht ;
	by PatientID TestDate ;
	if last.PatientID;
	where height = . or height ne .;
run ;/*64 */&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;There's no error&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 19:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486800#M126717</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-08-14T19:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: observations discrepency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486806#M126719</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am trying to add a variable called height to my cohort dataset by &lt;STRONG&gt;left joining&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;
&lt;PRE&gt;*height most recent height within 30 days prior to the index date;
proc sql ;
	create table _02a_ht as 
	select a.*, b.labcomponent, b.TestResultCleaned,b.TestDate,
	case 
		when (a.index_date-30) le b.TestDate le a.index_date  and b.labcomponent ='Body Height' and b.TestResultCleaned ne .
		then b.TestResultCleaned 
		else .
	end as height	
	from _02a_ecog2 as a
	&lt;FONT size="5" color="#800080"&gt;&lt;STRONG&gt;inner join&lt;/STRONG&gt;&lt;/FONT&gt; dfi_panc.vitals as b 
	on a.PatientID=b.PatientID and b.labcomponent ='Body Height'
	order by a.PatientID,b.TestDate;
quit ;/*3463 */

*making sure the testdate is 30 days prior the index date;
data _02a_testdate;	
	set _02a_ht ;
	by PatientID TestDate ;
	if last.PatientID;
	where height = . or height ne .;
run ;/*64 */&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Try changing inner join to left join?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 20:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486806#M126719</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-14T20:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: observations discrepency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486808#M126720</link>
      <description>&lt;P&gt;While you may start with 92 in your cohort this bit of code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;inner join dfi_panc.vitals as b &lt;BR /&gt; on a.PatientID=b.PatientID and b.labcomponent ='Body Height'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;has the potential to remove patientid values either because it does not appear in both data sets OR the only match in set b does not have "Body Height" as the value for labcomponent. Possibly due to spelling differences.&lt;/P&gt;
&lt;P&gt;By definition from the online documentation:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;An &lt;A class="glossTerm" id="GTn0highcrgwez8hn168sagz7klq2g" target="_blank"&gt;&lt;/A&gt;inner join returns only the subset of rows from the first table that matches rows from the second table.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 14 Aug 2018 20:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486808#M126720</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-14T20:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: observations discrepency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486810#M126721</link>
      <description>&lt;P&gt;I changed that to a left join but now i have 89 obsv&amp;nbsp;still not 92&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 20:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486810#M126721</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-08-14T20:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: observations discrepency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486811#M126722</link>
      <description>&lt;P&gt;WHERE filters out the data. If you remove that do you get the records you want?&lt;/P&gt;
&lt;P&gt;Look at the missing records and determine what condition is excluding them....with less than a 100 records you can manually verify it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/208127"&gt;@manya92&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I changed that to a left join but now i have 89 obsv&amp;nbsp;still not 92&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 20:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486811#M126722</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-14T20:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: observations discrepency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486812#M126723</link>
      <description>Sorry, not the WHERE but this likely filters out the rest: and b.labcomponent ='Body Height'</description>
      <pubDate>Tue, 14 Aug 2018 20:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486812#M126723</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-14T20:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: observations discrepency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486816#M126724</link>
      <description>&lt;P&gt;Okay, now i have 89 obvs , i want to see which obsv&amp;nbsp;from the prev dataset haev&amp;nbsp;been deleted ?&amp;nbsp;how do i see that?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 20:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/observations-discrepency/m-p/486816#M126724</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-08-14T20:22:39Z</dc:date>
    </item>
  </channel>
</rss>

