<?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: finding index date and intervals in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835655#M35965</link>
    <description>Thats what i did, thank you so much!</description>
    <pubDate>Wed, 28 Sep 2022 15:48:39 GMT</pubDate>
    <dc:creator>Banke</dc:creator>
    <dc:date>2022-09-28T15:48:39Z</dc:date>
    <item>
      <title>finding index date and intervals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835597#M35961</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to find continuous eligibility of certain patients with insurance. Each patient appear multiple times with different prescription dates (variable = fill_date). As a first step, i want to find the first date they filled the prescription (index date) and 180 days before and after that date. The date format is MMDDYY10. and I would like to convert to numeric so that i can subtract and add 180 from this. I have attached the code. I have to find the first prescription date for each patient. I would appreciate if you please help me verify my code and how I can convert the date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/**what i have***/&lt;/P&gt;
&lt;P&gt;patient ID&amp;nbsp; &amp;nbsp; fill date&lt;/P&gt;
&lt;P&gt;patient 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 02/23/2001&lt;/P&gt;
&lt;P&gt;patient 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 02/25/2001&lt;/P&gt;
&lt;P&gt;patient 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 03/14/2003&lt;/P&gt;
&lt;P&gt;patient 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/01/2006&lt;/P&gt;
&lt;P&gt;patient 2&amp;nbsp; &amp;nbsp; &amp;nbsp; 10/14/2001&lt;/P&gt;
&lt;P&gt;patient 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;08/25/2008&lt;/P&gt;
&lt;P&gt;patient 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;07/14/2004&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/**what i want**/&lt;/P&gt;
&lt;P&gt;patient ID&amp;nbsp; &amp;nbsp; fill date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fill_date in days&amp;nbsp; &amp;nbsp;start date (+180)&amp;nbsp; &amp;nbsp;end date (-180)&lt;/P&gt;
&lt;P&gt;patient 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 02/23/2001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01234&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1054&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1414&lt;/P&gt;
&lt;P&gt;patient 2&amp;nbsp; &amp;nbsp; &amp;nbsp; 10/14/2001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 05555&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5375&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5735&lt;/P&gt;
&lt;P&gt;patient 3&amp;nbsp; &amp;nbsp; &amp;nbsp; 07/14/2004&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 33333&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 33153&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 33513&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA = XX;
BY PATIENT_ID FILL_DATE DESCENDING FILL_DATE;
RUN;

/** IDENTIFYING FIRST.FILL DATE**/
DATA INDEX_MONTH;
DO UNTIL (LAST.PATIENT_ID);
SET XX;
BY PATIENT_ID FILL_DATE;
IF FIRST.PATIENT_ID THEN INDEX_DT = FILL_DATE;
END;
RUN;

/**check**/
PROC PRINT DATA = MYHUMANA.DXMED (OBS = 100);
VAR PATIENT_ID FILL_DATE GENERIC_DRUG_NAME NDC;  
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 15:16:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835597#M35961</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2022-09-28T15:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: finding index date and intervals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835600#M35962</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The date format is MMDDYY10. and I would like to convert to numeric so that i can subtract and add 180 from this.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you mean that the format as seen by SAS (in PROC CONTENTS or elsewhere) is MMDDYY10. ? Or do you mean that it looks to you like MMDDYY10. before you read in the data, but it shows up as character in SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If the date format is MMDDYY10. in SAS (in PROC CONTENTS or elsewhere), then the variable is numeric (so you don't need to convert it), and you can add or subtract 180 by adding or subtracting. Example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start_date_plus_180 = fill_date + 180;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please do not provide data as Excel files. Many of us will not download Excel files, they can be a security threat. The proper way to provide data is via &lt;FONT color="#FF0000"&gt;working&lt;/FONT&gt; SAS data step code which you can type in yourself or use &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Sep 2022 14:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835600#M35962</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-28T14:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: finding index date and intervals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835648#M35963</link>
      <description>Ok, thank you. I have removed the attachment, its a dummy sample but thank you for showing me the right way.The date format as seen by SAS is MMDDYY10. (informat is DATETIME20.). It appears as such too. Using your code gave me the following, thank you. &lt;BR /&gt;patient ID    fill date            start date (+180)   end date (-180)&lt;BR /&gt;&lt;BR /&gt;patient 1      04/25/2015         20023                    20383&lt;BR /&gt;&lt;BR /&gt;patient 2      12/13/2016          20621                    20981&lt;BR /&gt;&lt;BR /&gt;patient 3      12/30/2016          20638                    20998&lt;BR /&gt;&lt;BR /&gt;Can you please help me check if my initial step of finding the first fill_date for each patient. Thank you</description>
      <pubDate>Wed, 28 Sep 2022 15:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835648#M35963</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2022-09-28T15:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: finding index date and intervals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835651#M35964</link>
      <description>&lt;P&gt;To find the first date for each patient, you have to sort by patient and date (if it is not already sorted) and then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data first_date;
    set have;
    by patient;
    if first.patient;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Sep 2022 15:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835651#M35964</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-28T15:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: finding index date and intervals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835655#M35965</link>
      <description>Thats what i did, thank you so much!</description>
      <pubDate>Wed, 28 Sep 2022 15:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835655#M35965</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2022-09-28T15:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: finding index date and intervals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835659#M35966</link>
      <description>&lt;P&gt;I have an additional question please, i am trying to identifying the first fill date (first time the patient filled the prescription which will be the oldest date), i had sorted by patient id and date with the descending option&amp;nbsp; and then output first_id. I am confused as the descending option may sort from the newest prescription date to the oldest, so should i output last.id instead? Thank you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA = MEDICATION;
BY PATIENT_ID FILL_DATE DESCENDING FILL_DATE;
RUN;

DATA INDEX_DATE;
DO UNTIL (LAST.PATIENT_ID);
SET MEDICATION;
BY PATIENT_ID FILL_DATE ;
IF FIRST.PATIENT_ID THEN INDEX_DT = FILL_DATE;
END;
RUN;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Sep 2022 16:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/finding-index-date-and-intervals/m-p/835659#M35966</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2022-09-28T16:02:26Z</dc:date>
    </item>
  </channel>
</rss>

