<?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: Calculating Days within a given year. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169159#M32433</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Following on from that&amp;nbsp; and trying to explain it a bit better if a patient&amp;nbsp; had a diagnosis of 12apr2012 and their enrollment start date was 12apr2010 and their enrollment end date of 18may 2012 i want to calculate the number of days of enrollment just in the year of diagnosis so only want to return the number of days of enrollment in 2012 and not include any days prior to 2012 or post 2012.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Oct 2014 07:16:14 GMT</pubDate>
    <dc:creator>lisahoward</dc:creator>
    <dc:date>2014-10-02T07:16:14Z</dc:date>
    <item>
      <title>Calculating Days within a given year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169158#M32432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I am trying calculate enrollment days for a given patient in a given year that has a diagnosis of interest within that year.&amp;nbsp; The criteria is that a patient must have 300 days of enrollment within the same year as their diagnosis.&amp;nbsp; Does anyone have any code I can use to calculate that any given diagnosis in any year from 2004 to 2012 also has the corresponding 300 days of valid enrollment days for the same year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.g diagnosis index date 20th Jan 2011.&amp;nbsp;&amp;nbsp; Patient must have 300 days combined before and after that date for 2011.&amp;nbsp; I only want to search in 2011 so i need some logic that searchs number of days prior to diagnosis Indexdate and post DIAGNOSIS&amp;nbsp; index date but only within the SAME year of diagnosis index date (2011) .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 06:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169158#M32432</guid>
      <dc:creator>lisahoward</dc:creator>
      <dc:date>2014-10-02T06:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Days within a given year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169159#M32433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Following on from that&amp;nbsp; and trying to explain it a bit better if a patient&amp;nbsp; had a diagnosis of 12apr2012 and their enrollment start date was 12apr2010 and their enrollment end date of 18may 2012 i want to calculate the number of days of enrollment just in the year of diagnosis so only want to return the number of days of enrollment in 2012 and not include any days prior to 2012 or post 2012.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 07:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169159#M32433</guid>
      <dc:creator>lisahoward</dc:creator>
      <dc:date>2014-10-02T07:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Days within a given year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169160#M32434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a look at interval function INTX, INTCK.&amp;nbsp; With these and you two dates, you can get a result of how many days/months years etc.&amp;nbsp; Also you could, as dates/times are numeric, just do end_date - start_date (sometimes +1 depending on specs).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 07:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169160#M32434</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-10-02T07:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Days within a given year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169161#M32435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PPost a sample of what your data looks like and what you want results to look like. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 09:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169161#M32435</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-10-02T09:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Days within a given year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169162#M32436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What happens if the "enrollment" is considerably before the end date, such as enrollment of 10 Dec 2012 and end date of 20 July 2014?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have the dates as SAS date values then you might want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Days = min (enddate-enrollmentdate, endate - mdy(1,1,year(enddate))); &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 14:40:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169162#M32436</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-10-02T14:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Days within a given year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169163#M32437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like you need some if statements, if I am understanding correctly?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would this work for you?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;format enroll_start_date enroll_end_date diag_date date9.;&lt;/P&gt;&lt;P&gt;enroll_start_date = '12apr2010'd;&lt;/P&gt;&lt;P&gt;enroll_end_date = '18may2012'd;&lt;/P&gt;&lt;P&gt;diag_date = '12apr2012'd;&lt;/P&gt;&lt;P&gt;if year(enroll_start_date) = year(diag_date) then&lt;/P&gt;&lt;P&gt; enroll_days = enroll_end_date - enroll_start_date;&lt;/P&gt;&lt;P&gt;else if year(enroll_end_date) = year(diag_date) then&lt;/P&gt;&lt;P&gt; enroll_days = enroll_end_date - mdy(1,1,year(enroll_end_date));&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt; enroll_days = 0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 16:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169163#M32437</guid>
      <dc:creator>Malv72</dc:creator>
      <dc:date>2014-10-02T16:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Days within a given year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169164#M32438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not sure what your enrollment data looks like but if you only want the number of enrollment days in the diagnosis year then you need to get the beginning and ending enrollment period for that particular year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format enroll_start_date enroll_end_date diag_date mmddyy10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; enroll_start_date = '01mar2010'd;&lt;/P&gt;&lt;P&gt; enroll_end_date = '31may2013'd;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; diag_date = '12apr2010'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; diag_date = '05jan2011'd;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format yr_enroll_start_date yr_enroll_end_date mmddyy10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*****************************************************************/&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*&amp;nbsp;&amp;nbsp;&amp;nbsp; create yr enrollment information for the yr of the diag */&lt;/P&gt;&lt;P&gt; /******************************************************************/&lt;/P&gt;&lt;P&gt;/* if the enrollment end date is after the end of the year of the diag,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; then set the yr enrollment end date to the last day of the diag year */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if year(enroll_end_date) &amp;gt; year(diag_date) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yr_enroll_end_date = intnx('year', diag_date, 0, 'ending');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else yr_enroll_end_date = enroll_end_date;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* if the enrollment start date is prior to the year of the&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diag, then set the yr enrollment start date to the beginning of the&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diag year */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if year(enroll_start_date) &amp;lt; year(diag_date) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yr_enroll_start_date = intnx('year',diag_date,0,'beginning');&lt;/P&gt;&lt;P&gt;&amp;nbsp; else yr_enroll_start_date = enroll_start_date;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; days = yr_enroll_end_date - yr_enroll_start_date + 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if days &amp;gt;= 300 then valid_enrollment = 'Y';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else valid_enrollment = 'N';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 17:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Days-within-a-given-year/m-p/169164#M32438</guid>
      <dc:creator>ewmoses</dc:creator>
      <dc:date>2014-10-02T17:49:48Z</dc:date>
    </item>
  </channel>
</rss>

