<?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: calculate number of days covered in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443370#M110914</link>
    <description>&lt;P&gt;&amp;nbsp;Because the data are PROC SORTed by MBRID DRUG_ID DOS, all records for the same drug are consecutive and in chronological order.&amp;nbsp; If you study use&amp;nbsp;"FIRST."&amp;nbsp;automatic dummy variables that arises from use of the BY statement in the data step, you'll see it is easy to determine whether the record-in-hand is the first record for a given drug, or not.&amp;nbsp; If it's the first, I use DOS as startdate.&amp;nbsp; But if not I compare DOS to the prior (DOS+SUPPLY) to see whether there is an overlap.&amp;nbsp; If there is, then I move startdate to the maximum of the current DOS vs (1+prior end_date).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you think I am double counting a day with multiple drugs?&amp;nbsp; Did you simulate some test data and look at the results?&amp;nbsp; If not I recommend you create a dataset having 2 records with the same date range but different drugs.&amp;nbsp; Run it through the program and see whether it provides what you requested.&amp;nbsp; My understanding of your request was the you wanted to count a day as covered if it had ANY drug.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, for cases with 2 records of the same drug on the same DOS, do you believe that the program fails to recognize the increased supply, and therefore extends the days covered?&amp;nbsp; Again, make a test data set, run the program to test your assumption.&amp;nbsp; It will help you understand the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If any of these tests do not produce what you request, then provide a dataset of the incoming data, and a dataset of the desired resulting data.&amp;nbsp; That will make it clear to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, instead of 01jan2016 through 31dec2016, you want a different coverage period: index_date through end_date (not to be confused with the end_date I created in my proposed solution).&amp;nbsp; Are those values constant over the entire data set?&amp;nbsp; If so, just change the Macrovariables LOBOUND and UPBOUND.&amp;nbsp; And the proc sort, can&lt;/P&gt;
&lt;P&gt;use a WHERE statement of&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;FONT color="#0000ff" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; where&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; dos&amp;lt;&amp;amp;upbound &lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;and dos+supply&amp;gt;=&amp;amp;lobound&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Use of &amp;amp;refyear is no longer useful.&amp;nbsp; You'll also have to change the bounds of the DO loop in the data step, but I leave it to you to determine the appropriate "tweak".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should be able to determine how to change the remainder of the program&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Sasfont"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Mar 2018 15:52:01 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-03-07T15:52:01Z</dc:date>
    <item>
      <title>calculate number of days covered &amp; 80% adherence for multiple prescriptions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443095#M110829</link>
      <description>&lt;P&gt;Hello SAS experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to request for a help to calculate number of days covered &amp;amp; 80% adherence for multiple prescriptions for a patient . Use the Drug ID field of NDC codes to determine if the prescriptions are the same or different. Here are different scenarios I need to capture. Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a) If multiple prescriptions for different medications are dispensed on the same day, calculate the number of days covered by a&amp;nbsp; medication using the prescriptions with the longest days supply.&lt;/P&gt;&lt;P&gt;b) For multiple different prescriptions dispensed on different days with overlapping days supply, count&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;each day in the treatment period only once&amp;nbsp;.&lt;/P&gt;&lt;P&gt;c) If multiple prescriptions for the same medication are dispensed on the same day&lt;BR /&gt;or on different days, sum the days supply and use the total to calculate the number of days covered by a&amp;nbsp; medication . For example, three prescriptions for the same medication are dispensed on the same day, each with a 30-day supply. Sum the days supply for a total of 90 days covered by the medication. Subtract any days supply that extends beyond December 31 of the measurement year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the sample data:&lt;/P&gt;&lt;P&gt;Mbrid&amp;nbsp; &amp;nbsp; &amp;nbsp;NDC&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DOS&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;supply drug_id&lt;/P&gt;&lt;P&gt;3A790&amp;nbsp; &amp;nbsp; &amp;nbsp;551110&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02/10/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 90&amp;nbsp; &amp;nbsp; d04105&lt;BR /&gt;3A790&amp;nbsp; &amp;nbsp; &amp;nbsp;651112&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02/10/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 60&amp;nbsp; &amp;nbsp; d04106&lt;/P&gt;&lt;P&gt;3A790&amp;nbsp; &amp;nbsp; &amp;nbsp;012390&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 05/20/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 90&amp;nbsp; &amp;nbsp; d04107&lt;BR /&gt;3A790&amp;nbsp; &amp;nbsp; 123456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06/20/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;90&amp;nbsp; &amp;nbsp; d04108&lt;/P&gt;&lt;P&gt;3A790&amp;nbsp; &amp;nbsp; &amp;nbsp;581111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;08/24/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 90&amp;nbsp; &amp;nbsp; d04109&lt;BR /&gt;3A790&amp;nbsp; &amp;nbsp; &amp;nbsp;581113&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 08/24/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 90&amp;nbsp; &amp;nbsp; d04109&lt;/P&gt;&lt;P&gt;3A790&amp;nbsp; &amp;nbsp; &amp;nbsp;591114&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 09/24/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 90&amp;nbsp; &amp;nbsp; d04109&lt;BR /&gt;3A790&amp;nbsp; &amp;nbsp; &amp;nbsp;591115&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 10/16/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 90&amp;nbsp; &amp;nbsp; d04109&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;KK&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2018 23:36:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443095#M110829</guid>
      <dc:creator>sunkarikk</dc:creator>
      <dc:date>2018-03-06T23:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: calculate number of days covered &amp; 80% adherence for multiple prescriptions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443103#M110831</link>
      <description>&lt;P&gt;You might want to share what the desired output would look like for your example input data. And what your individual variables mean.&lt;/P&gt;
&lt;P&gt;I guess that mbrid is something like "member id" and you are looking for a report on each individual mbrid?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is "measurement year" the same as the year of DOS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't describe what 80% adherence would be as far as I can see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 00:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443103#M110831</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-07T00:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: calculate number of days covered</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443108#M110834</link>
      <description>Yes Mbrid is nothing but "Member id", DOS is the fill_date of the&lt;BR /&gt;prescription. NDC is national drug code, SUPPLY is the days supply of&lt;BR /&gt;prescription , Drug_ID is nothing but grouping the NDCs by a drug ( used&lt;BR /&gt;to identify same or different medications ).&lt;BR /&gt;&lt;BR /&gt;I just need to check if the member achieved a PDC of at least 80% during&lt;BR /&gt;the treatment period.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The measurement year is calender year 2016.&lt;BR /&gt;&lt;BR /&gt;Please ignore Adherence it should be called PDC (Proportion of days&lt;BR /&gt;covered).&lt;BR /&gt;&lt;BR /&gt;The 80% PDC is nothing but (step 3 / step 2) Round (using the .5 rule).&lt;BR /&gt;&lt;BR /&gt;Step 2: Total Days in Treatment Period&lt;BR /&gt;Step3: Total Days Covered by a Medication in the Treatment Period&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;To determine the treatment period, calculate the number of days beginning&lt;BR /&gt;on the Index fill_date through the end of the measurement year. To ensure&lt;BR /&gt;that days supply that extends beyond the measurement year is not counted,&lt;BR /&gt;subtract any days supply that extends beyond December 31 of the measurement&lt;BR /&gt;year.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please let me know if you have any more questions.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;*Thanks a lot for looking into this.*</description>
      <pubDate>Wed, 07 Mar 2018 00:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443108#M110834</guid>
      <dc:creator>sunkarikk</dc:creator>
      <dc:date>2018-03-07T00:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: calculate number of days covered</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443116#M110837</link>
      <description>&lt;P&gt;So you only care about a single year?&amp;nbsp; What about drugs issued near the end of the prior year?&amp;nbsp; Is that data included?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 00:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443116#M110837</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-03-07T00:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: calculate number of days covered</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443119#M110838</link>
      <description>Yes . Please consider if any spill over days supply from 2015 to 2016&lt;BR /&gt;calender year.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;KK&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Mar 2018 01:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443119#M110838</guid>
      <dc:creator>sunkarikk</dc:creator>
      <dc:date>2018-03-07T01:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: calculate number of days covered</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443145#M110841</link>
      <description>&lt;P&gt;First filter out records with no supply in 2016 and sort them by mbrid drugid and dos.&amp;nbsp; This means you can capture reissue of a drug in consecutive records and see whether the supply overlaps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Mbrid :$5.  NDC   DOS :mmddyy10.  supply drug_id :$6.;
  format dos date9.;
datalines;
3A790     551110           02/10/2016      90    d04105
3A790     651112            02/10/2016      60    d04106
3A790     012390            05/20/2016      90    d04107
3A790    123456            06/20/2016       90    d04108
3A790     581111             08/24/2016      90    d04109
3A790     581113             08/24/2016      90    d04109
3A790     591114             09/24/2016      90    d04109
3A790     591115             10/16/2016      90    d04109
run;

%let refyear=2016;
%let lobound=%sysfunc(inputn(01jan&amp;amp;refyear,date9.));
%let upbound=%sysfunc(inputn(31dec&amp;amp;refyear,date9.));
%let caldays=%eval(1+&amp;amp;upbound-&amp;amp;lobound);
%put _user_;

proc sort ;
  by mbrid drug_id dos;
  where dos&amp;lt;"31dec&amp;amp;refyear"d  and dos+supply&amp;gt;="01jan&amp;amp;refyear"d;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The LOBOUND and UPBOUND values are being generated as the numeric values for 01jan2016 and 31dec2016, to use latter as array bounds.&amp;nbsp; The array COVDATES will therefore be indexed on date value:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep mbrid pdc);
  array covdates{&amp;amp;lobound:&amp;amp;upbound} _temporary_;

  set have;
  by mbrid drug_id;
  if first.mbrid then call missing(of covdates{*});

  possible_start=lag(dos)+lag(supply);
  if first.drug_id then start_date=dos;
  else start_date=max(dos,possible_start);
  end_date=(start_date+supply-1);

  start_date=max(start_date,&amp;amp;lobound);
  end_date=min(end_date,&amp;amp;upbound);

  do d=start_date to end_date;
    covered{d}=1;
  end;

  if last.mbrid;
  pdc=sum(of covered{*})/dim(covered);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A start date and end date have to be determined for each supply. If it's&amp;nbsp;the first record for a given&amp;nbsp;drug the startdate is DOS and enddate is DOS+SUPPLY.&amp;nbsp; But later records have to be examined to see&amp;nbsp;by how much, if any, overlap there is with preceding records for the same drug:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=mbrid pdc ncovered);

  array covdates{&amp;amp;lobound:&amp;amp;upbound} _temporary_;
  retain end_date;

  set have;
  by mbrid drug_id;
  if first.mbrid then call missing(of covdates{*},end_date);

  if first.drug_id then start_date=dos;
  else start_date=max(dos,end_date+1);
  end_date=start_date+supply-1;

  do d=max(start_date,"01jan&amp;amp;refyear"d) to min(end_date,"31dec&amp;amp;refyear"d);
     covdates{d}=1;
  end;

  if last.mbrid;

  ncovered=sum(of covdates{*});
  pdc=ncovered/&amp;amp;caldays;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice the "do d=" loop only coveres the 2016 portion of start_date to end_date.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 01:47:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443145#M110841</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-03-07T01:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: calculate number of days covered</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443150#M110843</link>
      <description>&lt;P&gt;Great! Thanks a lot&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;mkeintz .&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="login-bold"&gt;&amp;nbsp;I really appreciate your quick response. I will test run the code against the real data and let you know. Thanks a lot again.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 01:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443150#M110843</guid>
      <dc:creator>sunkarikk</dc:creator>
      <dc:date>2018-03-07T01:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: calculate number of days covered</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443183#M110855</link>
      <description>&lt;P&gt;Hi Mkeintz,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help me to tweak your code if the "have" dataset has index_date and end_date. I need PDC between index_date and end_date. Also&amp;nbsp; can you please tell me where you are looking for same or different medications?&amp;nbsp;I need to find&amp;nbsp;if&amp;nbsp;&lt;SPAN&gt;multiple prescriptions for &lt;STRONG&gt;different medications&lt;/STRONG&gt; are &lt;STRONG&gt;dispensed on the same day&lt;/STRONG&gt;, calculate the number of days covered by a&amp;nbsp; medication using the prescriptions with the &lt;STRONG&gt;longest days supply,&lt;/STRONG&gt;&amp;nbsp;For multiple &lt;STRONG&gt;different prescriptions&lt;/STRONG&gt; dispensed on &lt;STRONG&gt;different days&lt;/STRONG&gt; with &lt;STRONG&gt;overlapping days&lt;/STRONG&gt; supply, count&amp;nbsp;each day in the treatment period &lt;STRONG&gt;only once&lt;/STRONG&gt;.&amp;nbsp;If &lt;STRONG&gt;multiple prescriptions for the same medication are dispensed on the same dayor on different days, sum the days supply&lt;/STRONG&gt; and use the total to calculate the number of days covered&amp;nbsp; Thank you in advance for your response.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; Mbrid :&lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;5&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;  NDC   DOS :mmddyy10&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;  supply drug_id :&lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;6&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;. index_date :mmddyy10. end_date :mmddyy10.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; dos index_date end_date date9&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
datalines&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;A790     &lt;SPAN class="token number"&gt;551110&lt;/SPAN&gt;           &lt;SPAN class="token number"&gt;02&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;10&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2016&lt;/SPAN&gt;      &lt;SPAN class="token number"&gt;90&lt;/SPAN&gt;    d04105   02/10/2016        12/31/2016
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;A790     &lt;SPAN class="token number"&gt;651112&lt;/SPAN&gt;            &lt;SPAN class="token number"&gt;02&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;10&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2016&lt;/SPAN&gt;      &lt;SPAN class="token number"&gt;60&lt;/SPAN&gt;    d04106  02/10/2016        12/31/2016
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;A790     &lt;SPAN class="token number"&gt;012390&lt;/SPAN&gt;            &lt;SPAN class="token number"&gt;05&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;20&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2016&lt;/SPAN&gt;      &lt;SPAN class="token number"&gt;90&lt;/SPAN&gt;    d04107  02/10/2016        12/31/2016
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;A790    &lt;SPAN class="token number"&gt;123456&lt;/SPAN&gt;            &lt;SPAN class="token number"&gt;06&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;20&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2016&lt;/SPAN&gt;       &lt;SPAN class="token number"&gt;90&lt;/SPAN&gt;    d04108  02/10/2016        12/31/2016
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;A790     &lt;SPAN class="token number"&gt;581111&lt;/SPAN&gt;             &lt;SPAN class="token number"&gt;08&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;24&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2016&lt;/SPAN&gt;      &lt;SPAN class="token number"&gt;90&lt;/SPAN&gt;    d04109 02/10/2016        12/31/2016
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;A790     &lt;SPAN class="token number"&gt;581113&lt;/SPAN&gt;             &lt;SPAN class="token number"&gt;08&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;24&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2016&lt;/SPAN&gt;      &lt;SPAN class="token number"&gt;90&lt;/SPAN&gt;    d04109 02/10/2016        12/31/2016
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;A790     &lt;SPAN class="token number"&gt;591114&lt;/SPAN&gt;             &lt;SPAN class="token number"&gt;09&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;24&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2016&lt;/SPAN&gt;      &lt;SPAN class="token number"&gt;90&lt;/SPAN&gt;    d04109 02/10/2016        12/31/2016
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;A790     &lt;SPAN class="token number"&gt;591115&lt;/SPAN&gt;             &lt;SPAN class="token number"&gt;10&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;16&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2016&lt;/SPAN&gt;      &lt;SPAN class="token number"&gt;90&lt;/SPAN&gt;    d04109 02/10/2016        12/31/2016
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 06:48:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443183#M110855</guid>
      <dc:creator>sunkarikk</dc:creator>
      <dc:date>2018-03-07T06:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: calculate number of days covered</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443370#M110914</link>
      <description>&lt;P&gt;&amp;nbsp;Because the data are PROC SORTed by MBRID DRUG_ID DOS, all records for the same drug are consecutive and in chronological order.&amp;nbsp; If you study use&amp;nbsp;"FIRST."&amp;nbsp;automatic dummy variables that arises from use of the BY statement in the data step, you'll see it is easy to determine whether the record-in-hand is the first record for a given drug, or not.&amp;nbsp; If it's the first, I use DOS as startdate.&amp;nbsp; But if not I compare DOS to the prior (DOS+SUPPLY) to see whether there is an overlap.&amp;nbsp; If there is, then I move startdate to the maximum of the current DOS vs (1+prior end_date).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you think I am double counting a day with multiple drugs?&amp;nbsp; Did you simulate some test data and look at the results?&amp;nbsp; If not I recommend you create a dataset having 2 records with the same date range but different drugs.&amp;nbsp; Run it through the program and see whether it provides what you requested.&amp;nbsp; My understanding of your request was the you wanted to count a day as covered if it had ANY drug.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, for cases with 2 records of the same drug on the same DOS, do you believe that the program fails to recognize the increased supply, and therefore extends the days covered?&amp;nbsp; Again, make a test data set, run the program to test your assumption.&amp;nbsp; It will help you understand the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If any of these tests do not produce what you request, then provide a dataset of the incoming data, and a dataset of the desired resulting data.&amp;nbsp; That will make it clear to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, instead of 01jan2016 through 31dec2016, you want a different coverage period: index_date through end_date (not to be confused with the end_date I created in my proposed solution).&amp;nbsp; Are those values constant over the entire data set?&amp;nbsp; If so, just change the Macrovariables LOBOUND and UPBOUND.&amp;nbsp; And the proc sort, can&lt;/P&gt;
&lt;P&gt;use a WHERE statement of&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;FONT color="#0000ff" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; where&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt; dos&amp;lt;&amp;amp;upbound &lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;and dos+supply&amp;gt;=&amp;amp;lobound&lt;/FONT&gt;&lt;FONT face="Sasfont"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Use of &amp;amp;refyear is no longer useful.&amp;nbsp; You'll also have to change the bounds of the DO loop in the data step, but I leave it to you to determine the appropriate "tweak".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should be able to determine how to change the remainder of the program&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Sasfont"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 15:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443370#M110914</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-03-07T15:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: calculate number of days covered</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443465#M110948</link>
      <description>&lt;P&gt;Thanks MKeintz. I will take a deeper dibe into the code and test it. One more clarification please. I noticed that you created 2 want datasets with PDC calculation in each of them. Are you showing 2 different methods of PDC calculation ?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 19:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443465#M110948</guid>
      <dc:creator>sunkarikk</dc:creator>
      <dc:date>2018-03-07T19:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: calculate number of days covered</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443583#M110985</link>
      <description>&lt;P&gt;That was just sloppy editing on my part.&amp;nbsp; They are a single technique, and I should have shown just one example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the second if you want the NCOVERED variable as well as PDC.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2018 01:38:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443583#M110985</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-03-08T01:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: calculate number of days covered</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443612#M110998</link>
      <description>Great! Thanks a lot.&lt;BR /&gt;</description>
      <pubDate>Thu, 08 Mar 2018 03:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-number-of-days-covered-amp-80-adherence-for-multiple/m-p/443612#M110998</guid>
      <dc:creator>sunkarikk</dc:creator>
      <dc:date>2018-03-08T03:57:55Z</dc:date>
    </item>
  </channel>
</rss>

