So this looks like a rolling sum problem.
Try this to create just one of the sums:
proc sql;
create table a1 as
select
a.participant,
a.datetime,
(
select sum(app_1)
from final_master_sample b
where
a.participant = b.participant and
b.DATETIME between intnx('seconds',a.datetime,-60*60*24) and a.datetime
) as app_1_24
from final_master_sample a;
quit;
to see how much time this takes. If runtime is OK, expand for further values step-by-step.
I have the suspicion that this method will start to perform very badly quite quickly.
My preferred method for building rolling sums would be to create a correct sequence (ie your 5 minutes interval) first, inserting records with 0 values for every missing time point.
Then you can build an array that contains the rolling values (a FIFO queue) for your given time frame.
data want;
set have;
by participant;
array min_5 {288} app_1_1-app_1_288;
if first.participant
then do i = 1 to 288;
min_5{i} = 0;
end;
do i = 1 to 287;
min_5{i} = min_5{i+1};
end;
min_5{288} = app_1;
sum_app_1_1 = sum(of app_1_1-app_1_288);
drop i app_1_1-app_1_288;
run;
This is much better performancewise, as it only requires 1 sequential pass through the dataset (and probably a sort before that).
For longer time frames I would reduce the time-resolution (ie for months I would sum up the days first) to keep the array small enough so it fits into memory.
... View more