<?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 how to calculate time duration by id in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-time-duration-by-id/m-p/651606#M195523</link>
    <description>&lt;P&gt;My data looks like:&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; Start_day&amp;nbsp; &amp;nbsp; End_day&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;1 - 5/1/20 - 5/31/20&lt;/DIV&gt;&lt;DIV&gt;1 - 6/6/20 - 7/5/20&lt;/DIV&gt;&lt;DIV&gt;1 - 7/8/20 - 8/7/20&lt;/DIV&gt;&lt;DIV&gt;1 - 9/9/20-10/8/20&lt;/DIV&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to first calculate the gap between a person's last end day and the next start day. e.g. for person 1, the gap should be 6/6/20 - 5/31/30 =6 days (which I already calculated for each person successfully).&lt;/P&gt;&lt;P&gt;Then, I want to calculate the duration for a person if he/she has no gap &amp;gt; 30 days. e.g. person 1 has gap &amp;gt; 30 days at the 4th row, so the duration should be&amp;nbsp;&lt;SPAN&gt;8/7/20 minus 5/1/20 (99 days).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Plus,&amp;nbsp;&amp;nbsp;a person could have multiple durations if he/she has more than one gap (&amp;gt;30 days). e.g.&amp;nbsp;&lt;/SPAN&gt;A person could have first duration on 5/1/10 - 5/1/11. Then, he/she have a gap of, for example, 180 days and he/she start another period 11/1/2011 - 1/31/11 and then they could have another gap of &amp;gt; 30 days. Then they could start a third period.&lt;/P&gt;&lt;DIV&gt;The duration calculation is what I am struggling with.&lt;/DIV&gt;&lt;DIV&gt;Any suggestion?&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;</description>
    <pubDate>Fri, 29 May 2020 00:40:08 GMT</pubDate>
    <dc:creator>longwen</dc:creator>
    <dc:date>2020-05-29T00:40:08Z</dc:date>
    <item>
      <title>how to calculate time duration by id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-time-duration-by-id/m-p/651606#M195523</link>
      <description>&lt;P&gt;My data looks like:&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; Start_day&amp;nbsp; &amp;nbsp; End_day&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;1 - 5/1/20 - 5/31/20&lt;/DIV&gt;&lt;DIV&gt;1 - 6/6/20 - 7/5/20&lt;/DIV&gt;&lt;DIV&gt;1 - 7/8/20 - 8/7/20&lt;/DIV&gt;&lt;DIV&gt;1 - 9/9/20-10/8/20&lt;/DIV&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to first calculate the gap between a person's last end day and the next start day. e.g. for person 1, the gap should be 6/6/20 - 5/31/30 =6 days (which I already calculated for each person successfully).&lt;/P&gt;&lt;P&gt;Then, I want to calculate the duration for a person if he/she has no gap &amp;gt; 30 days. e.g. person 1 has gap &amp;gt; 30 days at the 4th row, so the duration should be&amp;nbsp;&lt;SPAN&gt;8/7/20 minus 5/1/20 (99 days).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Plus,&amp;nbsp;&amp;nbsp;a person could have multiple durations if he/she has more than one gap (&amp;gt;30 days). e.g.&amp;nbsp;&lt;/SPAN&gt;A person could have first duration on 5/1/10 - 5/1/11. Then, he/she have a gap of, for example, 180 days and he/she start another period 11/1/2011 - 1/31/11 and then they could have another gap of &amp;gt; 30 days. Then they could start a third period.&lt;/P&gt;&lt;DIV&gt;The duration calculation is what I am struggling with.&lt;/DIV&gt;&lt;DIV&gt;Any suggestion?&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;</description>
      <pubDate>Fri, 29 May 2020 00:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-time-duration-by-id/m-p/651606#M195523</guid>
      <dc:creator>longwen</dc:creator>
      <dc:date>2020-05-29T00:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate time duration by id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-time-duration-by-id/m-p/651620#M195527</link>
      <description>Can you add a few IDs or more rows for the same ID with examples of multiple durations. Present other situations that could be more complex etc..</description>
      <pubDate>Fri, 29 May 2020 03:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-time-duration-by-id/m-p/651620#M195527</guid>
      <dc:creator>biopharma</dc:creator>
      <dc:date>2020-05-29T03:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate time duration by id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-time-duration-by-id/m-p/651622#M195529</link>
      <description>&lt;P&gt;And add the desired output.&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 03:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-time-duration-by-id/m-p/651622#M195529</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-29T03:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate time duration by id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-time-duration-by-id/m-p/651748#M195571</link>
      <description>&lt;P&gt;Question: are your start_day and end_day actually SAS date values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will in the long run save yourself a lot of headaches later if you get into the habit of using 4 digit years for display (unless of course you have a dinosaur-like boss that requires 2 digit years).&lt;/P&gt;
&lt;P&gt;Quick, tell me what the date is in words for 01/02/03.&lt;/P&gt;
&lt;P&gt;Without more information you might even get the wrong century.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 14:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-time-duration-by-id/m-p/651748#M195571</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-29T14:36:37Z</dc:date>
    </item>
  </channel>
</rss>

