<?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 Get right duration from multiple startdate &amp;amp; stopdate per person? proc sql / sas eg in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-right-duration-from-multiple-startdate-amp-stopdate-per/m-p/564538#M158372</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a cohort with their medication start date, end date and ID. I'm trying to identify new users in 2017, ie. no other prescription prior 1 year from their index date or they have a gap longer than a year is also qualified.&lt;/P&gt;&lt;P&gt;1st I pulled anyone with earliest startdate in 2017 (recode as indexdate),&amp;nbsp; then if any ID has an indexdate that's between&amp;nbsp; indexdate-365 and indexdate-1, then they are flagged as ineligible.&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table NewUserin2017_flag&lt;BR /&gt;as&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;select UserwithMedsin2017.patientuid,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sum (case when&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(startdate between indexdate-365 and indexdate-1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;then 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;end) as ineligible&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;from UserwithMedsin2017&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;left join work.patmedcatwithoutdupes Meds&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;on UserwithMedsin2017.patientuid=Meds.patientuid&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;group by UserwithMedsin2017.patientuid&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;having ineligible=0&lt;BR /&gt;;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;That's how I got my cohort. Then I was just looking through the raw data at one point, notice something I missed before, the raw data looks like below. For ID=1, 1st ob startdate=7/12/2016, &lt;SPAN&gt;2nd ob startdate=10/14/2017, &lt;/SPAN&gt;the gap is definitely over 1 year, which made this person qualified based on my calculation. However, when you look at the stopdate=10/14/2017. So he/she basically stopped this drug on that day, then got a new prescription on the same day. Which means this person never stopped the drug, ie. no gap between these two prescriptions, when you also look at stopdate. Sometime they definitely qualifies the way I define them, eg. ID2 &amp;amp; ID3.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It is rare to have a prescription over 1 year, but that one record just got stuck in my head, and I couldn't figure out a way to account this factor in my code. Could you help me? either SAS EG or proc sql is okay. How to count the stopdate into my code, to actually get the correct cohort, and sometime the enddate is missing. Is this a rolling date question? I don't even sure what type of question this is.&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data sample;
  informat startdate mmddyy10.;
  informat enddate mmddyy10.;
  input ID startdate enddate;
  format startdate enddate mmddyy10.;
  datalines;&lt;BR /&gt;   
1 7/12/2016  10/14/2017    
1 10/14/2017   .         
2 6/02/2014  12/17/2014 
2 12/22/2017 7/8/2018   &lt;BR /&gt;3 6/02/2016   .          
3 7/22/2017  7/8/2018    &lt;/PRE&gt;&lt;P&gt;I hope my long message makes sense to you. Thanks very much! I appreciate any hints and advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;J.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jun 2019 19:42:20 GMT</pubDate>
    <dc:creator>j_l1</dc:creator>
    <dc:date>2019-06-07T19:42:20Z</dc:date>
    <item>
      <title>Get right duration from multiple startdate &amp; stopdate per person? proc sql / sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-right-duration-from-multiple-startdate-amp-stopdate-per/m-p/564538#M158372</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a cohort with their medication start date, end date and ID. I'm trying to identify new users in 2017, ie. no other prescription prior 1 year from their index date or they have a gap longer than a year is also qualified.&lt;/P&gt;&lt;P&gt;1st I pulled anyone with earliest startdate in 2017 (recode as indexdate),&amp;nbsp; then if any ID has an indexdate that's between&amp;nbsp; indexdate-365 and indexdate-1, then they are flagged as ineligible.&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table NewUserin2017_flag&lt;BR /&gt;as&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;select UserwithMedsin2017.patientuid,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sum (case when&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(startdate between indexdate-365 and indexdate-1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;then 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;end) as ineligible&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;from UserwithMedsin2017&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;left join work.patmedcatwithoutdupes Meds&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;on UserwithMedsin2017.patientuid=Meds.patientuid&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;group by UserwithMedsin2017.patientuid&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;having ineligible=0&lt;BR /&gt;;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;That's how I got my cohort. Then I was just looking through the raw data at one point, notice something I missed before, the raw data looks like below. For ID=1, 1st ob startdate=7/12/2016, &lt;SPAN&gt;2nd ob startdate=10/14/2017, &lt;/SPAN&gt;the gap is definitely over 1 year, which made this person qualified based on my calculation. However, when you look at the stopdate=10/14/2017. So he/she basically stopped this drug on that day, then got a new prescription on the same day. Which means this person never stopped the drug, ie. no gap between these two prescriptions, when you also look at stopdate. Sometime they definitely qualifies the way I define them, eg. ID2 &amp;amp; ID3.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It is rare to have a prescription over 1 year, but that one record just got stuck in my head, and I couldn't figure out a way to account this factor in my code. Could you help me? either SAS EG or proc sql is okay. How to count the stopdate into my code, to actually get the correct cohort, and sometime the enddate is missing. Is this a rolling date question? I don't even sure what type of question this is.&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data sample;
  informat startdate mmddyy10.;
  informat enddate mmddyy10.;
  input ID startdate enddate;
  format startdate enddate mmddyy10.;
  datalines;&lt;BR /&gt;   
1 7/12/2016  10/14/2017    
1 10/14/2017   .         
2 6/02/2014  12/17/2014 
2 12/22/2017 7/8/2018   &lt;BR /&gt;3 6/02/2016   .          
3 7/22/2017  7/8/2018    &lt;/PRE&gt;&lt;P&gt;I hope my long message makes sense to you. Thanks very much! I appreciate any hints and advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;J.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 19:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-right-duration-from-multiple-startdate-amp-stopdate-per/m-p/564538#M158372</guid>
      <dc:creator>j_l1</dc:creator>
      <dc:date>2019-06-07T19:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Get right duration from multiple startdate &amp; stopdate per person? proc sql / sas eg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-right-duration-from-multiple-startdate-amp-stopdate-per/m-p/565045#M158557</link>
      <description>&lt;P&gt;Can you show what the result for that example data should look like?&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, 10 Jun 2019 20:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-right-duration-from-multiple-startdate-amp-stopdate-per/m-p/565045#M158557</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-10T20:26:42Z</dc:date>
    </item>
  </channel>
</rss>

