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;

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 8096 views
  • 7 likes
  • 8 in conversation