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.
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.