<?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: Identify procedure dates from diagnosis dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identify-procedure-dates-from-diagnosis-dates/m-p/867808#M342754</link>
    <description>&lt;P&gt;I suggest providing an actual meaning to us of the variables BIOP MRI MRI_BIOP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you only have month and year of diagnosis (why???) I would not assume a date of the 15th of the month for the diagnosis since you are looking for dates before and close. What if the date from biopsy is only a few days and the biopsy was after the 15th of the month of the diagnosis?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What, in terms of your problem, does this record contribute? No date at all. Should it be considered for any purpose? If so, what?&lt;/P&gt;
&lt;PRE&gt;A       .             04 2017 1 0 0&lt;/PRE&gt;
&lt;P&gt;Your really have to explain this:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;For example in Pt_id A,&amp;nbsp;03/25/2017(procedure date) is the closet date/pre to 08/15/2007(diagnosis date) &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The date of 8/15/2007 you are assuming for a diagnosis is a completely different Pt_id: B.&amp;nbsp; So why are you comparing anything related to Pt_id=A??? Not only that but 03/25/2017 is not "pre" 08/15/2007 in any case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should show what you expect the output data set to look like.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Apr 2023 16:53:08 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-04-03T16:53:08Z</dc:date>
    <item>
      <title>Identify procedure dates from diagnosis dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-procedure-dates-from-diagnosis-dates/m-p/867767#M342734</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Sorry this is a long text, am just trying to be well detailed.&lt;/P&gt;&lt;P&gt;I am trying to determine two&amp;nbsp; dates from a dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;. BIOPSY date which is define as the&amp;nbsp;closest date to but &lt;STRONG&gt;pre&lt;/STRONG&gt;&amp;nbsp;&lt;STRONG&gt;DIAGNOSIS date&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;. MRI date which is define as the closest to but &lt;STRONG&gt;pre BIOPSY date&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I was able to generate the&amp;nbsp;&lt;STRONG&gt;BIOPSY date &lt;/STRONG&gt;but I am struggling to get the&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt; MRI date. &lt;/STRONG&gt;&lt;FONT color="#000000"&gt;I&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;have variable BIOP, MRI &amp;amp; MRI_BIOP. These are variables I have generated when BIOP=1 or MRI=1 or MRI_BIOP=1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input pt_id $ Pdate:mmddyy10.&amp;nbsp; month_diag year_diag BIOP MRI MRI_BIOP ;&lt;BR /&gt;format date mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;A 09/01/2016&amp;nbsp; 04 2017 0 1 0&lt;BR /&gt;A 01/01/2017&amp;nbsp; 04 2017 0 1 0&lt;BR /&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;04 2017 1 0 0&lt;BR /&gt;A 03/25/2017&amp;nbsp; 04 2017 1 0 0&lt;BR /&gt;B 09/02/2007&amp;nbsp; 08 2007 1 0 0&lt;BR /&gt;B 06/15/2007&amp;nbsp; 08 2007 0 1 0&lt;/P&gt;&lt;P&gt;B 06/13/2007&amp;nbsp; 08 2007 0 1 0&lt;BR /&gt;B 07/28/2007&amp;nbsp; 08 2007 1 0 0&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data = have; by pt_ID Pdate ;proc print; run;&lt;BR /&gt;data want ;&lt;BR /&gt;set have ;&lt;BR /&gt;by pt_id date ;&lt;/P&gt;&lt;P&gt;/*Make a diagnosis date that is the 15thday of the month of diagnosis */&lt;/P&gt;&lt;P&gt;DiagDate = mdy(month_diag,15,year_diag) ;&lt;/P&gt;&lt;P&gt;retain dt_biop dt_mri ;&lt;/P&gt;&lt;P&gt;if first.pt_id then do ;&lt;BR /&gt;call missing(dt_biop,dt_mri) ;&lt;BR /&gt;end ;&lt;BR /&gt;if Pdate = . then dt_biop=. ;&lt;BR /&gt;else if Pdate &amp;lt;= DiagDate &amp;amp; biop=1 then dt_biop=Pdate ;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;if mri=1 &amp;amp; Pdate &amp;lt;= dt_biop then dt_mri=Pdate ;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;if last.pt_id ;&lt;/P&gt;&lt;P&gt;format DiagDate dt_biop dt_mri date9. ;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;OUTPUT I WANTED&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For example in Pt_id A,&amp;nbsp;03/25/2017(procedure date) is the closet date/pre to 08/15/2007(diagnosis date) when BIOP=1 so this is the BIOPSY date. The next date closet &amp;amp; pre to 03/25/2017 is&amp;nbsp;01/01/2017 when MRI=1, so this is suppose to be the MRI date.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In Pt_id B,&amp;nbsp;07/28/2007 is the closet &amp;amp; pre to&amp;nbsp;08/15/2007when BIOP=1 so this should be BIOPSY date then&amp;nbsp;06/15/2007 is the closet &amp;amp;pre&amp;nbsp;07/28/2007 when MRI=1 so this should be the MRI date. &lt;/STRONG&gt;Any help will be very appreciated. Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 14:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-procedure-dates-from-diagnosis-dates/m-p/867767#M342734</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2023-04-03T14:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: Identify procedure dates from diagnosis dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-procedure-dates-from-diagnosis-dates/m-p/867808#M342754</link>
      <description>&lt;P&gt;I suggest providing an actual meaning to us of the variables BIOP MRI MRI_BIOP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you only have month and year of diagnosis (why???) I would not assume a date of the 15th of the month for the diagnosis since you are looking for dates before and close. What if the date from biopsy is only a few days and the biopsy was after the 15th of the month of the diagnosis?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What, in terms of your problem, does this record contribute? No date at all. Should it be considered for any purpose? If so, what?&lt;/P&gt;
&lt;PRE&gt;A       .             04 2017 1 0 0&lt;/PRE&gt;
&lt;P&gt;Your really have to explain this:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;For example in Pt_id A,&amp;nbsp;03/25/2017(procedure date) is the closet date/pre to 08/15/2007(diagnosis date) &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The date of 8/15/2007 you are assuming for a diagnosis is a completely different Pt_id: B.&amp;nbsp; So why are you comparing anything related to Pt_id=A??? Not only that but 03/25/2017 is not "pre" 08/15/2007 in any case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should show what you expect the output data set to look like.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 16:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-procedure-dates-from-diagnosis-dates/m-p/867808#M342754</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-03T16:53:08Z</dc:date>
    </item>
  </channel>
</rss>

