<?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: Working with Time Intervals in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968967#M11403</link>
    <description>If you want to maximize the end time with stop, do so in a function:&lt;BR /&gt;MyEnd = min(MyStart + 1800,stop);</description>
    <pubDate>Fri, 13 Jun 2025 11:09:42 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2025-06-13T11:09:42Z</dc:date>
    <item>
      <title>Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968959#M11397</link>
      <description>&lt;P&gt;Apologies if this is already been posted, I'm new to this. I'm trying to get 30 min interval data or to the end time for Agent activity for work. the code I have is :-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;set schedule2;&lt;BR /&gt;format Mystart MyEnd tod8.;&lt;BR /&gt;do Mystart = Start to Stop by 1800;&lt;BR /&gt;MyEnd = MyStart + 1800;&lt;/P&gt;&lt;P&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works for the most part, but it's not working if the interval end time is like 16:45:00. This is what I have :-&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;02-Jun-25&lt;/TD&gt;&lt;TD&gt;Sick&lt;/TD&gt;&lt;TD&gt;09:00:00&lt;/TD&gt;&lt;TD&gt;16:45:00&lt;/TD&gt;&lt;TD&gt;465&lt;/TD&gt;&lt;TD&gt;16:00:00&lt;/TD&gt;&lt;TD&gt;16:30:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-Jun-25&lt;/TD&gt;&lt;TD&gt;Sick&lt;/TD&gt;&lt;TD&gt;09:00:00&lt;/TD&gt;&lt;TD&gt;16:45:00&lt;/TD&gt;&lt;TD&gt;465&lt;/TD&gt;&lt;TD&gt;16:30:00&lt;/TD&gt;&lt;TD&gt;17:00:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-Jun-25&lt;/TD&gt;&lt;TD&gt;Meal&lt;/TD&gt;&lt;TD&gt;16:45:00&lt;/TD&gt;&lt;TD&gt;17:15:00&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;16:45:00&lt;/TD&gt;&lt;TD&gt;17:15:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-Jun-25&lt;/TD&gt;&lt;TD&gt;Meal&lt;/TD&gt;&lt;TD&gt;16:45:00&lt;/TD&gt;&lt;TD&gt;17:15:00&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;17:15:00&lt;/TD&gt;&lt;TD&gt;17:45:00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;But what I want is :-&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;02-Jun-25&lt;/TD&gt;&lt;TD&gt;Sick&lt;/TD&gt;&lt;TD&gt;09:00:00&lt;/TD&gt;&lt;TD&gt;16:45:00&lt;/TD&gt;&lt;TD&gt;465&lt;/TD&gt;&lt;TD&gt;16:00:00&lt;/TD&gt;&lt;TD&gt;16:30:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-Jun-25&lt;/TD&gt;&lt;TD&gt;Sick&lt;/TD&gt;&lt;TD&gt;09:00:00&lt;/TD&gt;&lt;TD&gt;16:45:00&lt;/TD&gt;&lt;TD&gt;465&lt;/TD&gt;&lt;TD&gt;16:30:00&lt;/TD&gt;&lt;TD&gt;16:45:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-Jun-25&lt;/TD&gt;&lt;TD&gt;Meal&lt;/TD&gt;&lt;TD&gt;16:45:00&lt;/TD&gt;&lt;TD&gt;17:15:00&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;16:45:00&lt;/TD&gt;&lt;TD&gt;17:00:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-Jun-25&lt;/TD&gt;&lt;TD&gt;Meal&lt;/TD&gt;&lt;TD&gt;16:45:00&lt;/TD&gt;&lt;TD&gt;17:15:00&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;17:00:00&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;17:15:00&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I know I am missing something but I cannot figure it out. Can someone please assist.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 09:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968959#M11397</guid>
      <dc:creator>primmer300174</dc:creator>
      <dc:date>2025-06-13T09:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968963#M11399</link>
      <description>&lt;P&gt;Please explain further. You say you want 30 minutes intervals, but in the bottom table (which is what you want to get) you have mostly 15 minute intervals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, we would need to see a portion of the starting data, which you have not shown us. (In other words, we need to see a portion of data set SCHEDULE2)&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 10:25:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968963#M11399</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-06-13T10:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968964#M11400</link>
      <description>&lt;P&gt;The ask of me is to have interval data per agent for productivity. but if the interval ends at 16:45:00, that would be classed as 0.5 for that interval as they are not productive for the whole 30 min interval. Hope this clarifies what I have asked for&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 10:27:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968964#M11400</guid>
      <dc:creator>primmer300174</dc:creator>
      <dc:date>2025-06-13T10:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968965#M11401</link>
      <description>&lt;P&gt;Apart from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;s input, I don't understand why you have a do loop, since you're doing OUTPUT outside of the loop?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 10:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968965#M11401</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2025-06-13T10:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968966#M11402</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/475778"&gt;@primmer300174&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The ask of me is to have interval data per agent for productivity. but if the interval ends at 16:45:00, that would be classed as 0.5 for that interval as they are not productive for the whole 30 min interval. Hope this clarifies what I have asked for&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So, please explain why your desired data is a 30 minute interval for record 1, but 15 minute intervals for records 2 through 4. Also, please SHOW us a portion of the input data in data set SCHEDULE2.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 10:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968966#M11402</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-06-13T10:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968967#M11403</link>
      <description>If you want to maximize the end time with stop, do so in a function:&lt;BR /&gt;MyEnd = min(MyStart + 1800,stop);</description>
      <pubDate>Fri, 13 Jun 2025 11:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968967#M11403</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-06-13T11:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968975#M11406</link>
      <description>&lt;P&gt;I'm doing a loop and output so that it gives every iteration for the 30 mins interval I'm requiring&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 12:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968975#M11406</guid>
      <dc:creator>primmer300174</dc:creator>
      <dc:date>2025-06-13T12:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968978#M11407</link>
      <description>&lt;P&gt;First point is it will be easier for everyone (you included) if you provide the example data as a SAS data step.&amp;nbsp; And keep it small enough to demonstrate the issue.&lt;/P&gt;
&lt;P&gt;From your listing it looks like you started with two observations. But lets use a shorter time range for the first one.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input date :date. meal :$10. start :time. stop :time. value;
  format date yymmdd10. start stop tod8.;
cards;
02-Jun-25 Sick 09:00:00 10:45:00 465 
02-Jun-25 Meal 16:45:00 17:15:00 30 
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Second if you want the last interval to be capped at the STOP time then use the MIN() function.&lt;/P&gt;
&lt;P&gt;Third if don't want an extra interval that STARTS at the STOP time then add more logic to prevent that.&amp;nbsp; You might try subtracting a fraction of a second from the upper bound used in the DO loop.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  length interval Mystart MyEnd 8;
  do Mystart = Start to Stop-0.01 by '00:30:00't;
    interval=sum(interval,1);
    MyEnd = min(MyStart + '00:30:00't,stop);
    output;
  end;
  format Mystart MyEnd tod8.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note: Try to avoid using "magic" numbers in your code.&amp;nbsp; How is the next programmer that works on this program supposed to know why you used the number 1,800?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1749820847739.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107808iF2B14E04D35892D2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1749820847739.png" alt="Tom_0-1749820847739.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 13:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968978#M11407</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-13T13:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968985#M11408</link>
      <description>&lt;P&gt;Firstly, thank you for your advise, noted and will amend current and future codes to prevent the "magic" numbers etc. Makes sense to me but like you said, anyone else looking at it may not understand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is almost what I need. for row 5, where it says MyEnd at 17:15:00, think need to be 17:00:00 and then an additional to say MyStart 17:00:00 and MyEnd to say 17:15:00&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 14:19:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968985#M11408</guid>
      <dc:creator>primmer300174</dc:creator>
      <dc:date>2025-06-13T14:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968987#M11409</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/475778"&gt;@primmer300174&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Firstly, thank you for your advise, noted and will amend current and future codes to prevent the "magic" numbers etc. Makes sense to me but like you said, anyone else looking at it may not understand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is almost what I need. for row 5, where it says MyEnd at 17:15:00, think need to be 17:00:00 and then an additional to say MyStart 17:00:00 and MyEnd to say 17:15:00&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;said why do you want to switch from 30 minutes intervals to 15 minute intervals on that second subject?&amp;nbsp; How can the program know to treat that subject differently?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 14:46:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968987#M11409</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-13T14:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968989#M11410</link>
      <description>&lt;P&gt;I have to convert each duration into 30 minute intervals for comparing against the scheduled activity which is in 30 minute intervals.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what the Resource planning area have given me and will not change this. I am trying to work out how many agents I would have (whether fully or partly) in that 30 minute interval. I have examples where a break has been place at 10:55:00 - 11:05:00 which would mean I need to have the MyStart as 10:55:00 - MyEnd 11:05:00 and then an additional row that would say MyStart as 11:05:00 and MyEnd as 11:30:00.&lt;/P&gt;&lt;P&gt;Hope this make sense and clarifies the confusion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 14:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968989#M11410</guid>
      <dc:creator>primmer300174</dc:creator>
      <dc:date>2025-06-13T14:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968990#M11411</link>
      <description>&lt;P&gt;This is still confusing, as you've introduced a new concept of a 'break'.&amp;nbsp; Please provide an example of the sample data you HAVE (schedule2), and the output you WANT from that sample data.&amp;nbsp; &amp;nbsp;As a DATA step with CARDS statement, as Tom showed, and Paige asked for at the beginning of this thread.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 15:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968990#M11411</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2025-06-13T15:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968995#M11412</link>
      <description>&lt;P&gt;So you want to merge a series of 30 minutes intervals with your existing time period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could do something like this to calculate the intervals for each subject separately.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  retain window '00:30:00't;
  set have ;
  length interval Mystart MyEnd 8;
  base_time = window*int(start/window);
  do interval=1 by 1 until(MyEnd &amp;gt;= Stop);
    myend = base_time + interval*window;
    mystart = myend-window;
    output;
  end;
  format Mystart MyEnd tod8.;
  drop window base_time;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1749834091702.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107810iF6C7AC6CF69CE03C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1749834091702.png" alt="Tom_0-1749834091702.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Or you could generate all of the intervals in a 24 hour day and join the two datasets using PROC SQL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data intervals;
  do mystart=0 to '24:00:00't by '00:30:00't ;
    myend=mystart + '00:30:00't;
    output;
  end;
  format mystart myend tod8.;
run;

proc sql;
create table want as 
select a.*,b.*
from have a
  left join intervals b
  on a.start &amp;lt; b.myend
  and a.stop &amp;gt; b.mystart
order by a.date,b.mystart,b.myend
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_1-1749834426281.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107811i46B0CE7C5FE62C1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_1-1749834426281.png" alt="Tom_1-1749834426281.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You might want to add more logic if you want the MYstart and MYend times not extend beyond the start and stop times.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as 
select a.*
     , max(a.start,b.mystart) as MyStart format=tod8.
     , min(a.stop,b.myend) as MyEnd format=tod8.
from have a
  left join intervals b
  on a.start &amp;lt; b.myend
  and a.stop &amp;gt; b.mystart
order by a.date,b.mystart,b.myend
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1749834961033.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107812i8C9E8C0BCA832779/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1749834961033.png" alt="Tom_0-1749834961033.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 17:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/968995#M11412</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-13T17:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/969001#M11413</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/475778"&gt;@primmer300174&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have to convert each duration into 30 minute intervals for comparing against the scheduled activity which is in 30 minute intervals.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what the Resource planning area have given me and will not change this. I am trying to work out how many agents I would have (whether fully or partly) in that 30 minute interval. I have examples where a break has been place at 10:55:00 - 11:05:00 which would mean I need to have the MyStart as 10:55:00 - MyEnd 11:05:00 and then an additional row that would say MyStart as 11:05:00 and MyEnd as 11:30:00.&lt;/P&gt;
&lt;P&gt;Hope this make sense and clarifies the confusion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As an aside, you keep saying "30 minute interval" and then show something like "MyStart as 10:55:00 - MyEnd 11:05:00 and then an additional row that would say MyStart as 11:05:00 and MyEnd as 11:30:00." Neither of these start/end pairs have a 30 minute interval.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This sounds more like you have to&amp;nbsp;&lt;STRONG&gt;add an observation to the data set&lt;/STRONG&gt; when&amp;nbsp;an existing interval that does not end in either 00 or 30 minutes such that the additional observation starts at the end of the existing observation ends at such a multiple. Is this a clearer understanding of what your requirement is? If so, is there ever a requirement to add more than one observation and what in the data tells you that a particular observation should have such multiple extensions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the objective is to &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;count&lt;/STRONG&gt; &lt;/FONT&gt;intervals then I think that you don't need to add anything to the data. The INTCK function allows for custom intervals involving multiples of an existing unit.&lt;/P&gt;
&lt;P&gt;Consider this program which has a given start period and then increments and end period value starting one minute later and running for a bit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   starttime = '01:23:00't;
   do endtime   = '01:24:00't to '02:12:00't by 60;
      intervals = intck('minute30',starttime,endtime);
      output;
   end;
   format starttime endtime time.;
run;&lt;/PRE&gt;
&lt;P&gt;If you examine the output you will see that the interval count returned is 0 until the endtime value reaches 1:30:00 and then increments, then again at 2:00:00.&lt;/P&gt;
&lt;P&gt;So depending on your need you may either use this interval directly or add 1 to get a 3 for the number of 30 minute periods involved.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, computers are stupid and "30 minute interval" with no other information could start at 5 and go to 35 minutes or any other start/end. You need to explicitly state the periods need to end at minute 00 and 30.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 18:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/969001#M11413</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-06-13T18:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/969012#M11414</link>
      <description>&lt;P&gt;Yes. As others said there are too many things uncertain. If I understood what you meant.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
infile cards truncover expandtabs;
  input date :date. meal :$10. start :time. stop :time. value;
  format date yymmdd10. start stop tod8.;
cards;
02-Jun-25 Sick 16:00:00 16:45:00 465 
02-Jun-25 Meal 16:45:00 17:15:00 30
;
data gt30m le30m;
set have;
if intck('minutes',start,stop)&amp;gt;30 then output gt30m;
 else output le30m;
run;


data temp_gt30m;
 set gt30m;
 mystart=start;
 do i=start to stop;
   if i-mystart=1800 or i=stop then do;myend=i;output;mystart=i; end;
 end;
 drop i;
 format mystart myend tod8.;
 run;
 
data temp_le30m;
 set le30m;
 mystart=start; interval=(stop-start)/2;
 do i=start to stop;
   if i-mystart=interval or i=stop then do;myend=i;output;mystart=i; end;
 end;
 drop interval i;
 format mystart myend tod8.;
 run;

 data want;
 set temp_:;
 run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jun 2025 00:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/969012#M11414</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-06-15T00:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/969014#M11415</link>
      <description>&lt;P&gt;As everybody here is still forced to make&amp;nbsp;&lt;EM&gt;guesses&lt;/EM&gt; about your existing data and the data you want (which obviously makes it hard to come up with a working solution), you now &lt;STRONG&gt;MUST&lt;/STRONG&gt; post usable example data and the wanted result from that if you expect answers that make sense. PLEASE help us to help you.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jun 2025 11:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/969014#M11415</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-06-14T11:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Time Intervals</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/969071#M11416</link>
      <description>&lt;P&gt;Using the MINUTE30 interval should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  do interval=0 to intck('minute30',start,stop);
    MyStart=max(start,intnx('minute30',start,interval,'b'));
    MyEnd=min(stop,intnx('minute30',start,interval+1,'b'));
    output;
  end;
  format mystart myend tod8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-06-15 at 4.56.54 PM.png" style="width: 720px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107843i627CDB9B821DF7A1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-06-15 at 4.56.54 PM.png" alt="Screenshot 2025-06-15 at 4.56.54 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jun 2025 20:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Working-with-Time-Intervals/m-p/969071#M11416</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-15T20:57:27Z</dc:date>
    </item>
  </channel>
</rss>

