<?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: How long it took patients to get back an insurance? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/554464#M154242</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you please help me create a dummy variable (0,1) whether patient had ever/never enrolled in an insurance?&amp;nbsp; (date_diagnosis)=year(date pairs) .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe I should create a new post?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please re-post this as new topic. So that the community notices it.&lt;/P&gt;</description>
    <pubDate>Sat, 27 Apr 2019 09:45:15 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2019-04-27T09:45:15Z</dc:date>
    <item>
      <title>How long it took patients to get back an insurance?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/553475#M153915</link>
      <description>&lt;P&gt;Dear SAS experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like find out how long it took patients to get on the insurance coverage again. &lt;/P&gt;
&lt;P&gt;My data has date of diganosis (date_diagnosis) and date pairs where each pair measures the length of individual insurance coverage intervals.&lt;/P&gt;
&lt;P&gt;I'm trying to create a column which takes 0 when date_diagnosis falls inside any of date pairs and number of days, in other words, distance between date_diagnosis and the beginning of the next nearest insurance coverage as shown in the image,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12887"&gt;@ErikLund_Jensen&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, pat_id=6 was diagnosed for a condition in 15SEP2005. However, it was not contained in both date pairs shown in the image below. My goal is to calculate the distance between date_diagnosis and elig_beg2. AKA, the time until next insurance coverage. Output variable would be a column taking 0 through continuous numbers associated with a time until patient's next insurance coverage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="time until next coverage.png" style="width: 485px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/28957i14BF62F6FF08C0B9/image-size/large?v=v2&amp;amp;px=999" role="button" title="time until next coverage.png" alt="time until next coverage.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA HAVE;
format id 8. DATE_DIAGNOSIS elig_beg1 elig_end1 elig_beg2 elig_end2 elig_beg3 elig_end3 elig_beg4 elig_end4 elig_beg5 elig_end5 elig_beg6 elig_end6 elig_beg7 elig_end7 elig_beg8 elig_end8 date9.; 
informat DATE_DIAGNOSIS elig_beg1 elig_end1 elig_beg2 elig_end2 elig_beg3 elig_end3 elig_beg4 elig_end4 elig_beg5 elig_end5 elig_beg6 elig_end6 elig_beg7 elig_end7 elig_beg8 elig_end8 date9.; 
input ID DATE_DIAGNOSIS elig_beg1 elig_end1 elig_beg2 elig_end2 elig_beg3 elig_end3 elig_beg4 elig_end4 elig_beg5 elig_end5 elig_beg6 elig_end6 elig_beg7 elig_end7 elig_beg8 elig_end8; 
cards;
1 29MAR2005 01NOV2003 30NOV2003 01JAN2004 31JUL2004 01OCT2004 31DEC2004 01JUN2005 31JUL2005 01OCT2005 31JAN2006 01FEB2011 30JUN2011 01JAN2014 28FEB2014 01JAN2015 31JAN2017 
2 08JUN2005 01JAN2002 31JAN2002 01DEC2005 28FEB2013 01DEC2016 31DEC2016 01OCT2017 30NOV2017 . . . . . . . . 
3 24JUN2005 01JAN2002 31JAN2002 01AUG2002 30SEP2002 01NOV2004 31DEC2004 01JUL2011 31AUG2011 . . . . . . . . 
4 18JUL2005  01AUG2005 31DEC2006 01DEC2009 31DEC2010 . . . . . . . . . . . . 
5 15AUG2005 01MAY2002 31MAY2002 01MAR2003 31MAY2003 01OCT2003 30NOV2003 01JAN2004 29FEB2004 01APR2004 30APR2004 01APR2006 31MAY2006 01OCT2006 30NOV2006 . . 
6 15SEP2005 01MAR2005 31MAR2005 01FEB2006 28FEB2006 . . . . . . . . . . . . 
7 17OCT2005 01MAR2005 31MAY2005 01JAN2006 28FEB2006 01FEB2007 28FEB2007 . . . . . . . . . . 
8 30OCT2005 01JUN2005 30JUN2005 01AUG2005 30SEP2005 01MAY2006 30JUN2006 01NOV2009 31DEC2009 01MAY2011 30NOV2011 01JAN2013 28FEB2013 01DEC2013 30NOV2014 01MAR2015 31MAY2015 
9 10NOV2005 01JUN2004 30JUN2004 01SEP2004 31OCT2004 01MAY2005 30JUN2005 01SEP2006 30NOV2006 01FEB2007 30NOV2007 01NOV2008 31DEC2008 01APR2009 30APR2009 . . 
10 17NOV2018 01MAY2005 31JUL2005 01APR2006 31MAY2006 01APR2009 31MAY2009 01APR2010 30APR2010 01APR2011 30JUN2011 01MAR2012 30APR2012 01MAR2013 31MAR2013 01DEC2016 31DEC
11 10DEC2004 01NOV2004 30JUN2008 01OCT2008 30JUN2011 . . . . . . . . . . . . 
12 14DEC2004 01NOV2004 31OCT2008 . . . . . . . . . . . . . . 
13 01DEC2008 01NOV2004 31OCT2008 01DEC2008 31DEC2016 . . . . . . . . . . . . 
14 24DEC2004 01NOV2004 30JUN2005 . . . . . . . . . . . . . . . .
15 01DEC2004 01NOV2005 31JAN2017 . . . . . . . . . . . . . . . .
16 22DEC2005 01NOV2005 31DEC2016 . . . . . . . . . . . . . . . .
17 03DEC2009 01NOV2009 31DEC2016 01NOV2017 31DEC2017 . . . . . . . . . . . . 
18 01DEC2010 01NOV2010 31JUL2011 01NOV2013 31OCT2014 . . . . . . . . . . . . 
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2019 19:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/553475#M153915</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-04-24T19:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: How long it took patients to get back an insurance?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/553883#M154062</link>
      <description>&lt;P&gt;Can you please post what you expect as result for each observation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following step seems to create what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

   length distance 8;

   set have;

   array _begin[*] elig_beg:;
   array _end[*] elig_end:;

   do i = 1 to dim(_begin);
      if _begin[i] &amp;lt;= date_diagnosis &amp;lt;= _end[i] then do;
         distance = 0;
         leave;
      end;
   end;

   if missing(distance) then do;
      if date_diagnosis &amp;lt; elig_beg1 then do;
         distance = date_diagnosis - elig_beg1;
      end;
      else do;
         do i = 1 to dim(_begin) -1;
            if _end[i] &amp;lt; date_diagnosis &amp;lt; _begin[i+1] then do;
               distance = _begin[i+1] - date_diagnosis;
               leave;
            end;
         end;
      end;
   end;

   drop i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Next step: optimize the code, so to avoid the second loop.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 08:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/553883#M154062</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-04-25T08:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: How long it took patients to get back an insurance?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/553884#M154063</link>
      <description>&lt;P&gt;and a shorter version with only one loop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   length distance i 8;

   set have;

   array _begin[*] elig_beg:;
   array _end[*] elig_end:;


   do i = 1 to dim(_begin);
      if _begin[i] &amp;lt;= date_diagnosis &amp;lt;= _end[i] then do;
         distance = 0;
         leave;
      end;
      else do;
         if date_diagnosis &amp;lt; _begin[i] then do;            
            distance = _begin[i] - date_diagnosis;
            leave;
         end;
      end;
   end;

   drop i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Apr 2019 08:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/553884#M154063</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-04-25T08:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: How long it took patients to get back an insurance?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/553938#M154075</link>
      <description>Eurika! Bull's eye! Thanks a lot.</description>
      <pubDate>Thu, 25 Apr 2019 12:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/553938#M154075</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-04-25T12:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: How long it took patients to get back an insurance?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/554406#M154219</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you please help me create a dummy variable (0,1) whether patient had ever/never enrolled in an insurance?&amp;nbsp; (date_diagnosis)=year(date pairs) .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe I should create a new post?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 21:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/554406#M154219</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-04-26T21:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: How long it took patients to get back an insurance?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/554464#M154242</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you please help me create a dummy variable (0,1) whether patient had ever/never enrolled in an insurance?&amp;nbsp; (date_diagnosis)=year(date pairs) .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe I should create a new post?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please re-post this as new topic. So that the community notices it.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2019 09:45:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-long-it-took-patients-to-get-back-an-insurance/m-p/554464#M154242</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-04-27T09:45:15Z</dc:date>
    </item>
  </channel>
</rss>

