<?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 claims data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-claims-data/m-p/929174#M365604</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply and advice to reduce processing times. That's helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data set containing index date is a different dataset derived from medical and pharmacy claims and was irrelevant to this code - so did not share that portion of the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To answer your other question - 12 months prior means -&lt;/P&gt;&lt;P&gt;if the index date is (MMDDYY) 1/1/2017 then the patient should be enrolled in insurance from 1/1/2016 to at least 2/1/2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 May 2024 17:46:41 GMT</pubDate>
    <dc:creator>SSK_011523</dc:creator>
    <dc:date>2024-05-21T17:46:41Z</dc:date>
    <item>
      <title>Continuous enrollment claims data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-claims-data/m-p/929170#M365602</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using claims data for analysis and was stuck at one part in continuous enrollment. Any help would be appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need patients who are continuously enrolled for 12 months prior to the index date to at least one month and maximum of 12 months after the index date. A gap of 30 days is acceptable. Also, I'm interested in first enrollment period only.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the data I have&lt;/P&gt;&lt;P&gt;Data Test;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input patid $&amp;nbsp; dtstart :YYMMDD10. dtend : YYMMDD10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;format&amp;nbsp; dtstart YYMMDD10. dtend YYMMDD10.;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;001 2017-01-01 2017-01-31&lt;/P&gt;&lt;P&gt;001 2017-02-01 2017-02-31&lt;/P&gt;&lt;P&gt;001 2017-05-01 2017-05-31&lt;/P&gt;&lt;P&gt;002 2018-01-01 2018-01-31&lt;/P&gt;&lt;P&gt;002 2018-02-20 2018-04-31&lt;/P&gt;&lt;P&gt;003 2020-03-25 2020-12-31&lt;/P&gt;&lt;P&gt;003 2021-01-15 2021-08-31&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output (intermediate):&amp;nbsp;&lt;/P&gt;&lt;P&gt;001 2017-01-01 2017-02-31&lt;/P&gt;&lt;P&gt;001 2017-05-01 2017-05-31&lt;/P&gt;&lt;P&gt;002 2018-01-01 2018-04-31&lt;/P&gt;&lt;P&gt;003 2020-03-25 2021-08-31&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, patid 001 has two periods of continuous enrollment but I need only one enrollment period. So the desired output should be -&amp;nbsp;&lt;/P&gt;&lt;P&gt;001 2017-01-01 2017-02-31&lt;/P&gt;&lt;P&gt;002 2018-01-01 2018-04-31&lt;/P&gt;&lt;P&gt;003 2020-03-25 2021-08-31&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is the Code that I think would work. Not tried yet since data takes long time (~ a day) to process so I want to make sure I do it correctly. I just want to share my thought process&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data test1;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;set test (rename = (dtstart = start dtend = end)); ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;by patid;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;retain dtstart dtend enrolcnt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;label dtstart = "Enrollment Date Start"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dtend = "Enrollment Date End"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Enrolcnt = "Enrollment Period Count";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if first.patid then do;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dtstart = start;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;dtend = end;&amp;nbsp;&lt;/P&gt;&lt;P&gt;enrolcnt = 1;&amp;nbsp;&lt;/P&gt;&lt;P&gt;end;&amp;nbsp;&lt;/P&gt;&lt;P&gt;else do;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if dtend + 30 &amp;gt;=start then do;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if dtend &amp;lt; end then dtend = end;&amp;nbsp;&lt;/P&gt;&lt;P&gt;end;&amp;nbsp;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if last.patid then output;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once I get the continuous enrollment period, I will then select patients with continuos enrollment with enrollment start date&amp;nbsp; 12 months prior to the index date&amp;nbsp; &amp;nbsp;to at least one month and maximum of 12 months after the index date.&amp;nbsp; What confuses me is how to code for "at least" part in the previous statement. Should I create a new date variable as (new = index_date + 30)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS CODE (definitely incomplete) -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc sql;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table test3 as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;select a.*, b.dtstart, b.dtend&amp;nbsp;&lt;/P&gt;&lt;P&gt;from data_index_date as a right join test1 as b&lt;/P&gt;&lt;P&gt;on a.patid = b.patid&lt;/P&gt;&lt;P&gt;where intnx ('day', a.index_date, -365) GE b.dtstart and a.index_date LT b.dtend&lt;/P&gt;&lt;P&gt;order by patid;&amp;nbsp;&lt;/P&gt;&lt;P&gt;quit;&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>Tue, 21 May 2024 17:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-claims-data/m-p/929170#M365602</guid>
      <dc:creator>SSK_011523</dc:creator>
      <dc:date>2024-05-21T17:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment claims data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-claims-data/m-p/929172#M365603</link>
      <description>&lt;P&gt;I don't see any example of data containing an index date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You mention that you need "continuously enrolled for 12 months prior to the index date". How "prior"? What if the 12 months ends 4 years before the index date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data set is large then use a subset to test data such as select 10 or 100 patients to test the code against.&lt;/P&gt;
&lt;P&gt;If part of your concern about time is because you are reading from an external data base it may be appropriate to discuss how you are connecting and options, such as reducing the number of variables brought into SAS or other options to improve performance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are&amp;nbsp; you using&lt;/P&gt;
&lt;PRE&gt;intnx ('day', a.index_date, -365) &lt;/PRE&gt;
&lt;P&gt;instead of&lt;/P&gt;
&lt;PRE&gt;intnx ('year', a.index_date, -1) &lt;/PRE&gt;
&lt;P&gt;Does your process have a non-standard treatment of leap days when determining "year"?&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 14:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-claims-data/m-p/929172#M365603</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-05-24T14:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment claims data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-claims-data/m-p/929174#M365604</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply and advice to reduce processing times. That's helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data set containing index date is a different dataset derived from medical and pharmacy claims and was irrelevant to this code - so did not share that portion of the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To answer your other question - 12 months prior means -&lt;/P&gt;&lt;P&gt;if the index date is (MMDDYY) 1/1/2017 then the patient should be enrolled in insurance from 1/1/2016 to at least 2/1/2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 17:46:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-claims-data/m-p/929174#M365604</guid>
      <dc:creator>SSK_011523</dc:creator>
      <dc:date>2024-05-21T17:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment claims data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-claims-data/m-p/929215#M365623</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Test; 
infile cards expandtabs;
  input patid $  dtstart :YYMMDD10. dtend : YYMMDD10.;
 format  dtstart YYMMDD10. dtend YYMMDD10.; 
cards;
001 2017-01-01 2017-01-31
001 2017-02-01 2017-02-28
001 2017-05-01 2017-05-31
002 2018-01-01 2018-01-31
002 2018-02-20 2018-04-30
003 2020-03-25 2020-12-31
003 2021-01-15 2021-08-31
;

data temp;
 set test;
 do date=dtstart to dtend;
   output;
 end;
 format date yymmdd10.;
 keep patid date;
run;
proc sort data=temp out=temp2 nodupkey;
by patid date;
run;
data temp3;
 set temp2;
 by patid;
 if first.patid or dif(date) ne 1 then group+1;
run;
proc summary data=temp3 ;
by patid group;
var date;
output out=temp4 min=dtstart  max=dtend;
run;
data want;
 set temp4;
 by patid;
 if first.patid;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 May 2024 02:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-claims-data/m-p/929215#M365623</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-05-22T02:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Continuous enrollment claims data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-claims-data/m-p/929442#M365712</link>
      <description>&lt;P&gt;In the absence of sample data with index dates, in the form of a working data set, the below is not completely tested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First I think the task of generating a dataset of single "continuous" time spans for each PATID, is a relatively straightforward single data step (I use the corrected sample data provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp; &amp;nbsp; :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Test; 
infile cards expandtabs;
  input patid $  dtstart :YYMMDD10. dtend : YYMMDD10.;
 format  dtstart YYMMDD10. dtend YYMMDD10.; 
cards;
001 2017-01-01 2017-01-31
001 2017-02-01 2017-02-28
001 2017-05-01 2017-05-31
002 2018-01-01 2018-01-31
002 2018-02-20 2018-04-30
003 2020-03-25 2020-12-31
003 2021-01-15 2021-08-31
;

data single_spans (drop=first_: nxt_:  label='Single "continuous" enrollment spans');
  do until (last.patid or nxt_start&amp;gt;intnx('month',dtend,1,'same'));
    set test (keep=patid);
    by patid;
    merge test
          test (firstobs=2 keep=dtstart rename=(dtstart=nxt_start));
    if first.patid then first_dtstart=dtstart;
  end;
  if patid^=lag(patid);
  dtstart=first_dtstart;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The "do until" loop reads data until either the PATID is exhausted or the current obs is more than one month prior to the upcoming obs.&amp;nbsp; That builds a "continuous" span over a sequence of obs.&amp;nbsp; The subsequent&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  if patid^=lag(patid);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;guarantees that only the first such span for each PATID is output.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a dataset named INDEX_DATASET, sorted by PATID, and a variable INDEX_DATE, then (this is the untested portion):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge single_spans index_dataset ;
  by patid;
  where dtstart &amp;lt;= intnx('year',index_date,-1,'same')   and
        dtend   &amp;lt;= intnx('year',index_date,+1,'same')   and
        dtend   &amp;gt;= intnx('month',index_date,+1,'same') ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is intended to select observations in which DTSTART is at least 12 months prior to INDEX_DATE&amp;nbsp; and DTEND falls between 1 month and 1 year after INDEX_DATE.&amp;nbsp;&amp;nbsp;&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>Thu, 23 May 2024 17:13:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continuous-enrollment-claims-data/m-p/929442#M365712</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-05-23T17:13:25Z</dc:date>
    </item>
  </channel>
</rss>

