<?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: Count days between followed up events in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-days-between-followed-up-events/m-p/806321#M317659</link>
    <description>&lt;P&gt;Do you ever have multiple claims with the same date from a single patient?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, what rule do you want to establish for the new variable?&amp;nbsp; I can imagine a couple possibilities:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You would have some instances of days_between_events=0.&amp;nbsp; Or course this would be sensitive to reordering multiple claims for the same date.&lt;/LI&gt;
&lt;LI&gt;Each record on a given date has days_between_event set to the number of days since the last &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;earlier&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt; event?&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Wed, 06 Apr 2022 15:28:35 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-04-06T15:28:35Z</dc:date>
    <item>
      <title>Count days between followed up events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-days-between-followed-up-events/m-p/806283#M317635</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with claims of medication, each line / observation is one claim. I have the patient_id and the date of the claim. Now I created a variable, which counts up the several claims per patient between the years 2014 and 2020, beginning with 1 for the first claim, 2 for the second, 3 for the third... The maximum number viaries from patient to patient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to create a new variable, which counts the number of days between one claim to the previous within each patient, meaning the number of days between the second to the first, the third to the second...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would be very happy for your help, thank you in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 13:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-days-between-followed-up-events/m-p/806283#M317635</guid>
      <dc:creator>Tamino</dc:creator>
      <dc:date>2022-04-06T13:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Count days between followed up events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-days-between-followed-up-events/m-p/806297#M317643</link>
      <description>&lt;P&gt;Example data helps. Such things as are your dates actually SAS date values (amazing how many people ask about manipulating "dates" that are actually character strings)? Is the data already sorted by patient_id and date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dummy code assuming the response to both questions above is yes:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have; 
   by patient_id;
   days = dif(datevariable);
   if first.patiend_id then days=.; /* or 0 if peferred*/
run;&lt;/PRE&gt;
&lt;P&gt;When you use BY group processing in a data step SAS creates automatic variables that indicate whether a record is the first or last of a group, that are 1/0 for true/false, and referenced with the First. or Last. (pay attention to the dot in there).&lt;/P&gt;
&lt;P&gt;The DIF function returns the difference of the current value of a variable with that of the previous record if used carefully. Since SAS date values are a number of days then DIF is the number of days between dates.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 14:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-days-between-followed-up-events/m-p/806297#M317643</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-06T14:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Count days between followed up events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-days-between-followed-up-events/m-p/806320#M317658</link>
      <description>Thank you, that worked perfectly as I wanted.&lt;BR /&gt;Sorry about the dates, they were actually SAS date values.</description>
      <pubDate>Wed, 06 Apr 2022 15:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-days-between-followed-up-events/m-p/806320#M317658</guid>
      <dc:creator>Tamino</dc:creator>
      <dc:date>2022-04-06T15:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Count days between followed up events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-days-between-followed-up-events/m-p/806321#M317659</link>
      <description>&lt;P&gt;Do you ever have multiple claims with the same date from a single patient?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, what rule do you want to establish for the new variable?&amp;nbsp; I can imagine a couple possibilities:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You would have some instances of days_between_events=0.&amp;nbsp; Or course this would be sensitive to reordering multiple claims for the same date.&lt;/LI&gt;
&lt;LI&gt;Each record on a given date has days_between_event set to the number of days since the last &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;earlier&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt; event?&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 06 Apr 2022 15:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-days-between-followed-up-events/m-p/806321#M317659</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-04-06T15:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Count days between followed up events</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-days-between-followed-up-events/m-p/806443#M317732</link>
      <description>Thank you for your hint. I recognized that as I actually have some claims with the same date from a singe patient and the days_between_events=0 then. But as I want to exclude patients with less than 365d between their claims according to my research question, I ecluded them with a separate command (if claim_number&amp;gt;1 and days_between_events=0 then delete).</description>
      <pubDate>Thu, 07 Apr 2022 08:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-days-between-followed-up-events/m-p/806443#M317732</guid>
      <dc:creator>Tamino</dc:creator>
      <dc:date>2022-04-07T08:08:22Z</dc:date>
    </item>
  </channel>
</rss>

