BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Kurt_Bremser
Super User

As everybody here is still forced to make guesses about your existing data and the data you want (which obviously makes it hard to come up with a working solution), you now MUST post usable example data and the wanted result from that if you expect answers that make sense. PLEASE help us to help you.

Ksharp
Super User

Yes. As others said there are too many things uncertain. If I understood what you meant.

 

 

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)>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;

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 16 replies
  • 6589 views
  • 7 likes
  • 8 in conversation