<?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: Continuous enrollment 3 months prior to and 2 months after index medical event in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/847824#M335183</link>
    <description>&lt;P&gt;There's no Index date in your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we assume that the monthid values are continuous and never skip a month? Can we assume that the monthid values are numeric? (Or are they character?)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 05 Dec 2022 16:19:33 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-12-05T16:19:33Z</dc:date>
    <item>
      <title>Continuous enrollment 3 months prior to and 2 months after index medical event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/847803#M335180</link>
      <description>&lt;P&gt;I have insurance claims data, and I've identified cases that have had a particular medical event.&amp;nbsp; Now I'm trying to make sure that these cases were continuously enrolled 3 months prior to and 2 months after that event. In the following example data, let's say the index date for 1234 was Feb 15 2019.&amp;nbsp; That case would qualify.&amp;nbsp; But if the index date for 5678 was Jan 20 2022, that case would not qualify.&lt;/P&gt;
&lt;PRE&gt;memberid  monthid
1234      201811&lt;BR /&gt;1234      201812
1234      201901
1234      201902&lt;BR /&gt;1234      201903&lt;BR /&gt;1234      201904
5678      202110
5678      202111
5678      202201&lt;BR /&gt;5678      202202&lt;BR /&gt;5678      202203&lt;/PRE&gt;
&lt;P&gt;I searched and found some potentially useful code, but this is set up to find cases that have not had a gap in the last 12 months.&amp;nbsp; So how do I modify this to work with the index date and to search 3 months back and 2 months after?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
 by memberID monthID;
 if first.memberID then counter=0;
 if dif(monthID)&amp;gt;1 and mod(monthID,100) ne 1 then counter=0;
 if mod(monthID,100) eq 1 and dif(monthID) ne 89 then counter=0;
 counter+1;
 if counter ge 12 then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Dec 2022 15:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/847803#M335180</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2022-12-05T15:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment 3 months prior to and 2 months after index medical event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/847824#M335183</link>
      <description>&lt;P&gt;There's no Index date in your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we assume that the monthid values are continuous and never skip a month? Can we assume that the monthid values are numeric? (Or are they character?)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 16:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/847824#M335183</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-12-05T16:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment 3 months prior to and 2 months after index medical event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/847831#M335188</link>
      <description>&lt;P&gt;Sorry, I should have clarified.&amp;nbsp; Right now the index date is in another file, and I plan to link them by memberid.&amp;nbsp; There's a character version called service_date in the format 20191015 (Oct 15 2019), as well as a numeric version called service_date_d that contains the number of days since Jan 1 1960 (22,568 represents Oct 15 2019).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The monthid is character.&amp;nbsp; The months of coverage are independent of each other, so a case may be enrolled in 201910, skip 201911, and be re-enrolled in 201912.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 16:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/847831#M335188</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2022-12-05T16:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment 3 months prior to and 2 months after index medical event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848407#M335424</link>
      <description>&lt;P&gt;I've updated the data file so that it look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;memberid  monthid service_date   service_date_d
1234      201811   20190215      21595
1234      201812   20190215      21595
1234      201901   20190215      21595
1234      201902   20190215      21595
1234      201903   20190215      21595
1234      201904   20190215      21595
5678      202110   20220122      22665
5678      202111   20220122      22665
5678      202201   20220122      22665
5678      202202   20220122      22665
5678      202203   20220122      22665&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 19:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848407#M335424</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2022-12-07T19:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment 3 months prior to and 2 months after index medical event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848676#M335524</link>
      <description>&lt;P&gt;And what do you want your output dataset to look like?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2022 01:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848676#M335524</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-12-09T01:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment 3 months prior to and 2 months after index medical event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848683#M335526</link>
      <description>&lt;P&gt;Borrowing an idea from one of claims vendors (LABRX??) why not convert your coverage information into a string where each character represents a month.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input memberid $  monthid $;
cards;
1234      201811
1234      201812
1234      201901
1234      201902
1234      201903
1234      201904
5678      202110
5678      202111
5678      202201
5678      202202
5678      202203
;


%let basemonth='01JAN2018'd;
%let nmonths=%eval(5*12);

data coverage;
  do until (last.memberid);
    set have;
    by memberid;
    length coverage $&amp;amp;nmonths ;
    if first.memberid then coverage=repeat('.',&amp;amp;nmonths-1);
    offset=intck('month',&amp;amp;basemonth,servicedate);
    substr(coverage,offset+1,1)='X';
  end;
  keep memberid coverage;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1670555519238.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78223i9EFC969E6D28BB02/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1670555519238.png" alt="Tom_0-1670555519238.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now the test for continuous coverage is just a string comparison operation.&amp;nbsp; Use the INDEX date to calculate what part of teh string to look at.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   merge coverage service ;
   by memberid;
   offset=intck('month',&amp;amp;basemonth,input(monthid,yymmn6.));
   covered = ( 'XXXXX' = substrn(coverage,offset-2,5) );
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Dec 2022 03:16:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848683#M335526</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-09T03:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment 3 months prior to and 2 months after index medical event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848722#M335538</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;And what do you want your output dataset to look like?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The final file should have a single record for each member_ID and a flag variable (1=yes, 0=no) for continuous coverage around the timeframe of the index event.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2022 14:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848722#M335538</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2022-12-09T14:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment 3 months prior to and 2 months after index medical event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848724#M335539</link>
      <description>My biggest concern with this approach is that the coverage variable is not human-readable -- I can't easily tell which month/year is covered and which are not.  If there was some issue where everything was shifted by a month, I probably wouldn't be able to see it.</description>
      <pubDate>Fri, 09 Dec 2022 14:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848724#M335539</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2022-12-09T14:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment 3 months prior to and 2 months after index medical event</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848726#M335541</link>
      <description>&lt;P&gt;The other way is to convert your coverage into intervals.&amp;nbsp; I am sure this has been asked before here how to collapse overlapping of contiguous intervals.&amp;nbsp; Or you could just use the array approach implied by the string approach and then roll it out as a series of intervals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you just need to join by the memberid and whether the index date falls into the coverage interval.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select a.*
     , b.start
     , b.end
     , intnx('month',b.start,a.index) as months_pre
     , intnx('month',a.index,b.end) as months_post
from service a
left join coverge b
on a.memberid = b.memberid
and a.index between b.start and b.end 
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2022 14:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-3-months-prior-to-and-2-months-after-index/m-p/848726#M335541</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-09T14:43:22Z</dc:date>
    </item>
  </channel>
</rss>

